@antelopejs/interface-data-api 0.4.0 → 0.6.0
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/README.md +26 -22
- package/dist/antelope.test.js +1 -5
- package/dist/antelope.test.js.map +1 -1
- package/dist/components.d.ts +67 -39
- package/dist/components.js +106 -685
- package/dist/components.js.map +1 -1
- package/dist/index.d.ts +57 -68
- package/dist/index.js +114 -100
- package/dist/index.js.map +1 -1
- package/dist/internal/computed.d.ts +6 -0
- package/dist/internal/computed.js +51 -0
- package/dist/internal/computed.js.map +1 -0
- package/dist/internal/controller-types.d.ts +34 -0
- package/dist/internal/controller-types.js +4 -0
- package/dist/internal/controller-types.js.map +1 -0
- package/dist/internal/default-filter.d.ts +4 -0
- package/dist/internal/default-filter.js +29 -0
- package/dist/internal/default-filter.js.map +1 -0
- package/dist/internal/deferred-joined-stream.d.ts +11 -0
- package/dist/internal/deferred-joined-stream.js +125 -0
- package/dist/internal/deferred-joined-stream.js.map +1 -0
- package/dist/internal/extractors.d.ts +25 -0
- package/dist/internal/extractors.js +31 -0
- package/dist/internal/extractors.js.map +1 -0
- package/dist/internal/field-types.d.ts +199 -0
- package/dist/internal/field-types.js +4 -0
- package/dist/internal/field-types.js.map +1 -0
- package/dist/internal/filters.d.ts +6 -0
- package/dist/internal/filters.js +22 -0
- package/dist/internal/filters.js.map +1 -0
- package/dist/internal/foreign.d.ts +6 -0
- package/dist/internal/foreign.js +116 -0
- package/dist/internal/foreign.js.map +1 -0
- package/dist/internal/guards.d.ts +39 -0
- package/dist/internal/guards.js +116 -0
- package/dist/internal/guards.js.map +1 -0
- package/dist/internal/joined.d.ts +28 -0
- package/dist/internal/joined.js +127 -0
- package/dist/internal/joined.js.map +1 -0
- package/dist/internal/list.d.ts +16 -0
- package/dist/internal/list.js +182 -0
- package/dist/internal/list.js.map +1 -0
- package/dist/internal/meta-records.d.ts +19 -0
- package/dist/internal/meta-records.js +78 -0
- package/dist/internal/meta-records.js.map +1 -0
- package/dist/internal/properties.d.ts +4 -0
- package/dist/internal/properties.js +45 -0
- package/dist/internal/properties.js.map +1 -0
- package/dist/internal/prototypes.d.ts +14 -0
- package/dist/internal/prototypes.js +38 -0
- package/dist/internal/prototypes.js.map +1 -0
- package/dist/internal/read-properties.d.ts +3 -0
- package/dist/internal/read-properties.js +29 -0
- package/dist/internal/read-properties.js.map +1 -0
- package/dist/internal/table-reference.d.ts +11 -0
- package/dist/internal/table-reference.js +46 -0
- package/dist/internal/table-reference.js.map +1 -0
- package/dist/internal/tables.d.ts +28 -0
- package/dist/internal/tables.js +48 -0
- package/dist/internal/tables.js.map +1 -0
- package/dist/internal/validation.d.ts +12 -0
- package/dist/internal/validation.js +100 -0
- package/dist/internal/validation.js.map +1 -0
- package/dist/metadata.d.ts +27 -228
- package/dist/metadata.js +84 -213
- package/dist/metadata.js.map +1 -1
- package/dist/tests/components/access_control.test.js +28 -20
- package/dist/tests/components/access_control.test.js.map +1 -1
- package/dist/tests/components/computed.test.js +36 -27
- package/dist/tests/components/computed.test.js.map +1 -1
- package/dist/tests/components/cross_instance.test.js +8 -6
- package/dist/tests/components/cross_instance.test.js.map +1 -1
- package/dist/tests/components/deferred_joined.test.js +57 -54
- package/dist/tests/components/deferred_joined.test.js.map +1 -1
- package/dist/tests/components/extract_generic.test.d.ts +1 -0
- package/dist/tests/components/extract_generic.test.js +64 -0
- package/dist/tests/components/extract_generic.test.js.map +1 -0
- package/dist/tests/components/filter_comparisons.test.d.ts +1 -0
- package/dist/tests/components/filter_comparisons.test.js +34 -0
- package/dist/tests/components/filter_comparisons.test.js.map +1 -0
- package/dist/tests/components/filter_list_route.test.d.ts +1 -0
- package/dist/tests/components/filter_list_route.test.js +182 -0
- package/dist/tests/components/filter_list_route.test.js.map +1 -0
- package/dist/tests/components/filter_options.test.js +11 -10
- package/dist/tests/components/filter_options.test.js.map +1 -1
- package/dist/tests/components/foreign_computed.test.js +23 -14
- package/dist/tests/components/foreign_computed.test.js.map +1 -1
- package/dist/tests/components/foreign_joined.test.js +31 -27
- package/dist/tests/components/foreign_joined.test.js.map +1 -1
- package/dist/tests/components/joined.test.js +59 -45
- package/dist/tests/components/joined.test.js.map +1 -1
- package/dist/tests/components/listable.test.js +78 -58
- package/dist/tests/components/listable.test.js.map +1 -1
- package/dist/tests/components/localized_sort.test.js +14 -11
- package/dist/tests/components/localized_sort.test.js.map +1 -1
- package/dist/tests/components/mandatory.test.js +25 -25
- package/dist/tests/components/mandatory.test.js.map +1 -1
- package/dist/tests/components/modifier_key.test.js +27 -18
- package/dist/tests/components/modifier_key.test.js.map +1 -1
- package/dist/tests/components/parse_body.test.d.ts +1 -0
- package/dist/tests/components/parse_body.test.js +76 -0
- package/dist/tests/components/parse_body.test.js.map +1 -0
- package/dist/tests/components/parsed_value.test.js +23 -21
- package/dist/tests/components/parsed_value.test.js.map +1 -1
- package/dist/tests/components/partial_edit.test.js +38 -32
- package/dist/tests/components/partial_edit.test.js.map +1 -1
- package/dist/tests/components/per_action_access.test.js +20 -12
- package/dist/tests/components/per_action_access.test.js.map +1 -1
- package/dist/tests/components/prototype_named_filter.test.d.ts +1 -0
- package/dist/tests/components/prototype_named_filter.test.js +87 -0
- package/dist/tests/components/prototype_named_filter.test.js.map +1 -0
- package/dist/tests/components/validator.test.js +45 -37
- package/dist/tests/components/validator.test.js.map +1 -1
- package/dist/tests/components/written_row.test.d.ts +1 -0
- package/dist/tests/components/written_row.test.js +99 -0
- package/dist/tests/components/written_row.test.js.map +1 -0
- package/dist/tests/helpers/other-instance.d.ts +11 -1
- package/dist/tests/helpers/other-instance.js +35 -9
- package/dist/tests/helpers/other-instance.js.map +1 -1
- package/dist/tests/index/field_decorator_target.test.d.ts +1 -0
- package/dist/tests/index/field_decorator_target.test.js +20 -0
- package/dist/tests/index/field_decorator_target.test.js.map +1 -0
- package/dist/tests/index/get_guard.test.js +6 -6
- package/dist/tests/index/get_guard.test.js.map +1 -1
- package/dist/tests/index/inheritance.test.js +14 -9
- package/dist/tests/index/inheritance.test.js.map +1 -1
- package/dist/tests/index/metadata_names.test.d.ts +1 -0
- package/dist/tests/index/metadata_names.test.js +91 -0
- package/dist/tests/index/metadata_names.test.js.map +1 -0
- package/dist/tests/index/routes.test.js +49 -44
- package/dist/tests/index/routes.test.js.map +1 -1
- package/dist/tests/integration.test.d.ts +1 -1
- package/dist/tests/integration.test.js +66 -729
- package/dist/tests/integration.test.js.map +1 -1
- package/dist/tests/internal/controller-fields.test.d.ts +1 -0
- package/dist/tests/internal/controller-fields.test.js +25 -0
- package/dist/tests/internal/controller-fields.test.js.map +1 -0
- package/dist/tests/internal/http.d.ts +35 -0
- package/dist/tests/internal/http.js +56 -0
- package/dist/tests/internal/http.js.map +1 -0
- package/dist/tests/internal/shop-api.d.ts +1 -0
- package/dist/tests/internal/shop-api.js +331 -0
- package/dist/tests/internal/shop-api.js.map +1 -0
- package/dist/tests/internal/shop-schema.d.ts +162 -0
- package/dist/tests/internal/shop-schema.js +387 -0
- package/dist/tests/internal/shop-schema.js.map +1 -0
- package/dist/tests/utils.d.ts +8 -10
- package/dist/tests/utils.js +1 -3
- package/dist/tests/utils.js.map +1 -1
- package/dist/tests/utils.test.js +10 -11
- package/dist/tests/utils.test.js.map +1 -1
- package/docs/1.introduction.md +38 -35
- package/docs/10.joined.md +51 -40
- package/docs/11.computed.md +91 -47
- package/docs/2.data-controllers.md +50 -42
- package/docs/3.routes.md +156 -134
- package/docs/4.access-rights.md +48 -44
- package/docs/5.validators.md +65 -47
- package/docs/6.listable.md +53 -49
- package/docs/7.foreign-keys.md +55 -48
- package/docs/8.filters.md +65 -54
- package/docs/9.modifiers.md +29 -25
- package/package.json +34 -13
- package/skills/data-api-interface/SKILL.md +13 -3
- package/skills/data-api-interface/cases.json +99 -0
package/README.md
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@antelopejs/interface-data-api`
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
|
-
<a href="https://www.npmjs.com/package/@antelopejs/interface-data-api"><img alt="npm" src="https://img.shields.io/npm/v/@antelopejs/interface-data-api?style=for-the-badge&labelColor=000000&color=000000"></a>
|
|
5
|
-
<a href="./LICENSE"><img alt="License" src="https://img.shields.io/npm/l/@antelopejs/interface-data-api?style=for-the-badge&labelColor=000000&color=000000"></a>
|
|
6
|
-
<a href="https://discord.gg/
|
|
7
|
-
<a href="https://interfaces.antelopejs.com/docs/data-api"><img alt="Docs" src="https://img.shields.io/badge/Docs-18181B?style=for-the-badge&color=000000"></a>
|
|
4
|
+
<a href="https://www.npmjs.com/package/@antelopejs/interface-data-api"><img data-illustration alt="npm" src="https://img.shields.io/npm/v/@antelopejs/interface-data-api?style=for-the-badge&labelColor=000000&color=000000"></a>
|
|
5
|
+
<a href="./LICENSE"><img data-illustration alt="License" src="https://img.shields.io/npm/l/@antelopejs/interface-data-api?style=for-the-badge&labelColor=000000&color=000000"></a>
|
|
6
|
+
<a href="https://discord.gg/g4pFt6eXqu"><img data-illustration alt="Discord" src="https://img.shields.io/badge/Discord-18181B?logo=discord&style=for-the-badge&color=000000"></a>
|
|
7
|
+
<a href="https://interfaces.antelopejs.com/docs/data-api"><img data-illustration alt="Docs" src="https://img.shields.io/badge/Docs-18181B?style=for-the-badge&color=000000"></a>
|
|
8
8
|
</div>
|
|
9
9
|
|
|
10
|
-
CRUD REST endpoints
|
|
10
|
+
The AntelopeJS interface that generates CRUD REST endpoints from a database table. Declare a data controller and its fields, and it serves the `get`, `list`, `new`, `edit` and `delete` routes with access rules, validation and pagination.
|
|
11
|
+
|
|
12
|
+
Part of [AntelopeJS](https://github.com/AntelopeJS/antelopejs). Used by [AntelopeJS DMS](https://github.com/AntelopeJS/dms), the open-source back office for your PostgreSQL, MongoDB or RethinkDB database.
|
|
11
13
|
|
|
12
14
|
## What it offers
|
|
13
15
|
|
|
14
16
|
- `DataController` and `@RegisterDataController()` turn a table class into a controller with the default routes you pick from `DefaultRoutes`.
|
|
15
|
-
- `@Access
|
|
17
|
+
- `@Access` decides which fields each route reads and writes. `@Mandatory` and `@Validator` check the written values.
|
|
16
18
|
- `@Listable`, `@Sortable` and `@Filter` shape the paginated `list` route.
|
|
17
19
|
- `@Foreign`, `@Joined` and `@Computed` resolve references, flatten remote fields and add values computed in the database.
|
|
18
20
|
|
|
19
21
|
## Implementations
|
|
20
22
|
|
|
21
|
-
The package runs in your module and has no implementing module of its own. The project needs modules that implement the interfaces it builds on
|
|
23
|
+
The package runs in your module and has no implementing module of its own. The project needs modules that implement the interfaces it builds on.
|
|
22
24
|
|
|
23
25
|
| Interface | Module |
|
|
24
26
|
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
|
@@ -27,13 +29,13 @@ The package runs in your module and has no implementing module of its own. The p
|
|
|
27
29
|
|
|
28
30
|
## Install
|
|
29
31
|
|
|
30
|
-
Add the package and
|
|
32
|
+
Add the package and its peer interfaces to your module.
|
|
31
33
|
|
|
32
34
|
```bash
|
|
33
|
-
pnpm add @antelopejs/interface-data-api @antelopejs/interface-api @antelopejs/interface-database-decorators
|
|
35
|
+
pnpm add @antelopejs/interface-data-api @antelopejs/interface-api @antelopejs/interface-api-util @antelopejs/interface-core @antelopejs/interface-database @antelopejs/interface-database-decorators
|
|
34
36
|
```
|
|
35
37
|
|
|
36
|
-
Then add the implementations to the project
|
|
38
|
+
Then add the implementations to the project.
|
|
37
39
|
|
|
38
40
|
```bash
|
|
39
41
|
ajs project modules add @antelopejs/api @antelopejs/mongodb
|
|
@@ -101,7 +103,7 @@ export async function construct() {
|
|
|
101
103
|
}
|
|
102
104
|
```
|
|
103
105
|
|
|
104
|
-
The controller serves `GET /tasks/get?id=`, `GET /tasks/list`, `POST /tasks/new`, `PUT /tasks/edit?id=` and `DELETE /tasks/delete?id=`.
|
|
106
|
+
The controller serves `GET /tasks/get?id=`, `GET /tasks/list`, `POST /tasks/new`, `PUT /tasks/edit?id=` and `DELETE /tasks/delete?id=`. A field without `@Access` stays out of every response and every write, unless `@Joined` or `@Computed` makes it read-only.
|
|
105
107
|
|
|
106
108
|
## Documentation
|
|
107
109
|
|
|
@@ -119,21 +121,23 @@ The controller serves `GET /tasks/get?id=`, `GET /tasks/list`, `POST /tasks/new`
|
|
|
119
121
|
|
|
120
122
|
## Compatibility
|
|
121
123
|
|
|
122
|
-
|
|
124
|
+
The package declares these `@antelopejs/*` peer dependencies.
|
|
125
|
+
|
|
126
|
+
<!-- antelopejs-docs-compat:start -->
|
|
123
127
|
|
|
124
|
-
|
|
128
|
+
| Package | Supported | Tested with |
|
|
129
|
+
| ------------------------------------------- | ----------------- | ----------- |
|
|
130
|
+
| `@antelopejs/interface-api` | `>=0.3.0 <1.0.0` | `0.2.0` |
|
|
131
|
+
| `@antelopejs/interface-api-util` | `>=0.1.3 <1.0.0` | `0.3.0` |
|
|
132
|
+
| `@antelopejs/interface-core` | `>=0.2.4 <1.0.0` | `0.4.0` |
|
|
133
|
+
| `@antelopejs/interface-database` | `>=0.1.10 <1.0.0` | `0.3.0` |
|
|
134
|
+
| `@antelopejs/interface-database-decorators` | `>=0.1.10 <1.0.0` | `0.2.0` |
|
|
125
135
|
|
|
126
|
-
|
|
127
|
-
| ------------------------------------------- | ----------------- |
|
|
128
|
-
| `@antelopejs/interface-api` | `>=0.0.15 <1.0.0` |
|
|
129
|
-
| `@antelopejs/interface-api-util` | `>=0.1.3 <1.0.0` |
|
|
130
|
-
| `@antelopejs/interface-core` | `>=0.2.4 <1.0.0` |
|
|
131
|
-
| `@antelopejs/interface-database` | `>=0.1.10 <1.0.0` |
|
|
132
|
-
| `@antelopejs/interface-database-decorators` | `>=0.1.10 <1.0.0` |
|
|
136
|
+
<!-- antelopejs-docs-compat:end -->
|
|
133
137
|
|
|
134
138
|
## Contributing
|
|
135
139
|
|
|
136
|
-
Read [CONTRIBUTING.md](./CONTRIBUTING.md) before you open a pull request.
|
|
140
|
+
Read [CONTRIBUTING.md](./CONTRIBUTING.md) before you open a pull request. Run the local checks with these commands.
|
|
137
141
|
|
|
138
142
|
```bash
|
|
139
143
|
pnpm install
|
package/dist/antelope.test.js
CHANGED
|
@@ -22,11 +22,7 @@ exports.default = (0, config_1.defineConfig)({
|
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
24
|
api: {
|
|
25
|
-
source: {
|
|
26
|
-
type: "package",
|
|
27
|
-
package: "@antelopejs/api",
|
|
28
|
-
version: "1.3.0",
|
|
29
|
-
},
|
|
25
|
+
source: { type: "local", path: "node_modules/@antelopejs/api" },
|
|
30
26
|
config: {
|
|
31
27
|
publicBaseUrl: "http://127.0.0.1:5010",
|
|
32
28
|
servers: [{ protocol: "http", host: "127.0.0.1", port: 5010 }],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"antelope.test.js","sourceRoot":"","sources":["../src/antelope.test.ts"],"names":[],"mappings":";;AAAA,2EAA+D;AAC/D,8DAAiE;AAEjE,IAAI,MAAyB,CAAC;AAE9B,kBAAe,IAAA,qBAAY,EAAC;IAC1B,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EAAE,iBAAiB;IAC9B,OAAO,EAAE;QACP,KAAK,EAAE;YACL,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE;YACpC,eAAe,EAAE;gBACf,2BAA2B,EAAE,KAAK;gBAClC,gCAAgC,EAAE,SAAS;aAC5C;SACF;QACD,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,qBAAqB;gBAC9B,OAAO,EAAE,OAAO;aACjB;SACF;QACD,GAAG,EAAE;YACH,MAAM,EAAE
|
|
1
|
+
{"version":3,"file":"antelope.test.js","sourceRoot":"","sources":["../src/antelope.test.ts"],"names":[],"mappings":";;AAAA,2EAA+D;AAC/D,8DAAiE;AAEjE,IAAI,MAAyB,CAAC;AAE9B,kBAAe,IAAA,qBAAY,EAAC;IAC1B,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EAAE,iBAAiB;IAC9B,OAAO,EAAE;QACP,KAAK,EAAE;YACL,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE;YACpC,eAAe,EAAE;gBACf,2BAA2B,EAAE,KAAK;gBAClC,gCAAgC,EAAE,SAAS;aAC5C;SACF;QACD,OAAO,EAAE;YACP,MAAM,EAAE;gBACN,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,qBAAqB;gBAC9B,OAAO,EAAE,OAAO;aACjB;SACF;QACD,GAAG,EAAE;YACH,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,8BAA8B,EAAE;YAC/D,MAAM,EAAE;gBACN,aAAa,EAAE,uBAAuB;gBACtC,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;aAC/D;SACF;KACF;IACD,IAAI,EAAE;QACJ,MAAM,EAAE,YAAY;QACpB,KAAK,CAAC,KAAK;YACT,MAAM,GAAG,MAAM,8CAAiB,CAAC,MAAM,EAAE,CAAC;YAC1C,OAAO;gBACL,OAAO,EAAE;oBACP,OAAO,EAAE;wBACP,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,iBAAiB,EAAE;qBAC9D;iBACF;aACF,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,OAAO;YACX,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACtB,CAAC;KACF;CACF,CAAC,CAAC"}
|
package/dist/components.d.ts
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import type { DataModel } from "@antelopejs/interface-database-decorators/model";
|
|
2
1
|
import { type RequestContext } from "@antelopejs/interface-api";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
2
|
+
import type { Datum, SchemaInstance, Stream, Table, ValueProxy } from "@antelopejs/interface-database";
|
|
3
|
+
import "@antelopejs/interface-database";
|
|
4
|
+
import { type DataAPIMeta, type DataControllerCallbackWithOptions, type DataControllerInstance, type FieldFilter, type FieldValues, type RowFields } from "./metadata";
|
|
5
|
+
import * as extractors from "./internal/extractors";
|
|
6
|
+
import * as tables from "./internal/tables";
|
|
5
7
|
export declare namespace Parameters {
|
|
6
|
-
|
|
8
|
+
/**
|
|
9
|
+
* A request context as a data route holds it: {@link RegisterDataController}
|
|
10
|
+
* sets the route's entry on it. `Options` is what the route's parameter
|
|
11
|
+
* reads, which `WithOptions` wrote.
|
|
12
|
+
*/
|
|
13
|
+
interface DataRequestContext<Options = any> extends RequestContext {
|
|
14
|
+
dataAPIEntry?: DataControllerCallbackWithOptions<Options>;
|
|
15
|
+
}
|
|
16
|
+
/** The options the route's `WithOptions` set, none when it set none. */
|
|
17
|
+
function GetOptionOverrides<Options>(reqCtx: DataRequestContext<Options>): Partial<Options>;
|
|
7
18
|
/**
|
|
8
19
|
* Extracts request filters and mandatory route filters, with route field
|
|
9
20
|
* keys winning. A field the request filters once (`?filter_status=open`)
|
|
@@ -11,19 +22,27 @@ export declare namespace Parameters {
|
|
|
11
22
|
* (`?filter_age=ge:18&filter_age=lt:65`) gets them all, which a row must
|
|
12
23
|
* all pass. Returns fresh tuples.
|
|
13
24
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
25
|
+
function ExtractFilters(reqCtx: DataRequestContext<ListParameters>, meta: DataAPIMeta): Record<string, FieldFilter>;
|
|
26
|
+
type ParameterExtractor<Value> = extractors.ParameterExtractor<Value>;
|
|
27
|
+
type ParameterExtractors<T> = extractors.ParameterExtractors<T>;
|
|
28
|
+
const FromSearch: {
|
|
29
|
+
number: extractors.ParameterExtractor<number>;
|
|
30
|
+
int: extractors.ParameterExtractor<number>;
|
|
31
|
+
bool: extractors.ParameterExtractor<boolean>;
|
|
32
|
+
string: extractors.ParameterExtractor<string>;
|
|
33
|
+
numbers: extractors.ParameterExtractor<number[]>;
|
|
34
|
+
ints: extractors.ParameterExtractor<number[]>;
|
|
35
|
+
bools: extractors.ParameterExtractor<boolean[]>;
|
|
36
|
+
strings: extractors.ParameterExtractor<string[]>;
|
|
20
37
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Builds a route's parameters: the options its `WithOptions` set, then each
|
|
40
|
+
* extracted field those options leave out. An extractor of `undefined` is
|
|
41
|
+
* skipped like an absent key. {@link ExtractFilters} also runs for a route
|
|
42
|
+
* that sets `filters`, since it combines them with the request's.
|
|
43
|
+
*/
|
|
44
|
+
function ExtractGeneric<T extends Record<string, any>>(reqCtx: DataRequestContext<T>, meta: DataAPIMeta, dynamic: ParameterExtractors<T>): Partial<T>;
|
|
45
|
+
interface ListParameters {
|
|
27
46
|
/**
|
|
28
47
|
* The filters of the request, by field; a row passes every filter of
|
|
29
48
|
* every field. Mandatory route filters when supplied through
|
|
@@ -39,40 +58,42 @@ export declare namespace Parameters {
|
|
|
39
58
|
noPluck?: boolean;
|
|
40
59
|
pluckMode?: string;
|
|
41
60
|
}
|
|
42
|
-
|
|
43
|
-
|
|
61
|
+
const List: () => import("@antelopejs/interface-core/decorators").PropertyDecorator & import("@antelopejs/interface-core/decorators").ParameterDecorator;
|
|
62
|
+
interface GetParameters {
|
|
44
63
|
id: string;
|
|
45
64
|
index?: string;
|
|
46
65
|
noForeign?: string;
|
|
47
66
|
}
|
|
48
|
-
|
|
49
|
-
|
|
67
|
+
const Get: () => import("@antelopejs/interface-core/decorators").PropertyDecorator & import("@antelopejs/interface-core/decorators").ParameterDecorator;
|
|
68
|
+
interface NewParameters {
|
|
50
69
|
noMandatory?: string;
|
|
51
70
|
}
|
|
52
|
-
|
|
53
|
-
|
|
71
|
+
const New: () => import("@antelopejs/interface-core/decorators").PropertyDecorator & import("@antelopejs/interface-core/decorators").ParameterDecorator;
|
|
72
|
+
interface EditParameters {
|
|
54
73
|
id: string;
|
|
55
74
|
index?: string;
|
|
56
75
|
noMandatory?: string;
|
|
57
76
|
}
|
|
58
|
-
|
|
59
|
-
|
|
77
|
+
const Edit: () => import("@antelopejs/interface-core/decorators").PropertyDecorator & import("@antelopejs/interface-core/decorators").ParameterDecorator;
|
|
78
|
+
interface DeleteParameters {
|
|
60
79
|
id: string[];
|
|
61
80
|
}
|
|
62
|
-
|
|
63
|
-
export {};
|
|
81
|
+
const Delete: () => import("@antelopejs/interface-core/decorators").PropertyDecorator & import("@antelopejs/interface-core/decorators").ParameterDecorator;
|
|
64
82
|
}
|
|
65
83
|
export declare namespace Query {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
84
|
+
/**
|
|
85
|
+
* The database model a controller holds under its `@ModelReference` field,
|
|
86
|
+
* typed by the table rows it reads.
|
|
87
|
+
*/
|
|
88
|
+
type ModelInstance = tables.ModelInstance;
|
|
89
|
+
function GetModel(obj: DataControllerInstance, meta: DataAPIMeta): ModelInstance;
|
|
69
90
|
function Foreign(db: SchemaInstance<any>, meta: DataAPIMeta, query: Stream<any>, pluck?: Set<string>): Stream<any>;
|
|
70
91
|
function Foreign(db: SchemaInstance<any>, meta: DataAPIMeta, query: Datum<any>, pluck?: Set<string>): Datum<any>;
|
|
71
92
|
function Joined(db: SchemaInstance<any>, meta: DataAPIMeta, query: Stream<any>, only?: Set<string>): Stream<any>;
|
|
72
93
|
function Joined(db: SchemaInstance<any>, meta: DataAPIMeta, query: Datum<any>, only?: Set<string>): Datum<any>;
|
|
73
94
|
function Computed(db: SchemaInstance<any>, meta: DataAPIMeta, query: Stream<any>, only?: Set<string>): Stream<any>;
|
|
74
95
|
function Computed(db: SchemaInstance<any>, meta: DataAPIMeta, query: Datum<any>, only?: Set<string>): Datum<any>;
|
|
75
|
-
function ReadProperties(obj:
|
|
96
|
+
function ReadProperties(obj: DataControllerInstance, meta: DataAPIMeta, dbData: RowFields, action?: string, onlyList?: boolean): Promise<RowFields>;
|
|
76
97
|
/**
|
|
77
98
|
* Writes the writable fields of `bodyData` into a database row.
|
|
78
99
|
*
|
|
@@ -83,8 +104,8 @@ export declare namespace Query {
|
|
|
83
104
|
* row and only their setters run: an absent field keeps its stored value,
|
|
84
105
|
* `null` clears it.
|
|
85
106
|
*/
|
|
86
|
-
function WriteProperties(obj:
|
|
87
|
-
function Get(table: Table<
|
|
107
|
+
function WriteProperties(obj: DataControllerInstance, meta: DataAPIMeta, bodyData: FieldValues, action?: string, existingDBData?: RowFields): Promise<RowFields>;
|
|
108
|
+
function Get<T extends object>(table: Table<T>, id: string | ValueProxy<string>, index?: string): import("@antelopejs/interface-database").SingleSelection<T> | Datum<T | null>;
|
|
88
109
|
interface ListOptions {
|
|
89
110
|
/**
|
|
90
111
|
* Return the joined field names {@link List} did not materialize as the
|
|
@@ -94,6 +115,13 @@ export declare namespace Query {
|
|
|
94
115
|
*/
|
|
95
116
|
exposeDeferredJoined?: boolean;
|
|
96
117
|
}
|
|
118
|
+
/** What {@link List} takes after the request context. */
|
|
119
|
+
type ListTail = [
|
|
120
|
+
sorting?: [string, "asc" | "desc" | undefined],
|
|
121
|
+
filters?: Record<string, FieldFilter>,
|
|
122
|
+
db?: SchemaInstance<any>,
|
|
123
|
+
options?: ListOptions
|
|
124
|
+
];
|
|
97
125
|
/**
|
|
98
126
|
* Builds the filtered and sorted stream of a list request along with its
|
|
99
127
|
* total count. Joined fields that no filter or sort references are not
|
|
@@ -104,7 +132,7 @@ export declare namespace Query {
|
|
|
104
132
|
* since no lookup can be built without one — the raw stream is returned
|
|
105
133
|
* and the third element names the joined fields left for the caller.
|
|
106
134
|
*/
|
|
107
|
-
function List<T extends Record<string, any>>(obj:
|
|
135
|
+
function List<T extends Record<string, any>>(obj: DataControllerInstance, meta: DataAPIMeta, request: Table<T>, reqCtx: RequestContext, ...[sorting, filters, db, options]: ListTail): [sorted: Stream<T>, total: Datum<number>, deferredJoined: Set<string>];
|
|
108
136
|
/** How {@link ListPage} reads one page of a {@link List} stream. */
|
|
109
137
|
interface ListPageOptions {
|
|
110
138
|
offset: number;
|
|
@@ -139,7 +167,7 @@ export declare namespace Query {
|
|
|
139
167
|
}
|
|
140
168
|
export declare namespace Validation {
|
|
141
169
|
/** A request body, parsed. */
|
|
142
|
-
type RequestBody =
|
|
170
|
+
type RequestBody = FieldValues;
|
|
143
171
|
/** The `code` of a 400 naming the mandatory fields a body lacks. */
|
|
144
172
|
const MISSING_MANDATORY_FIELDS = "missing_mandatory_fields";
|
|
145
173
|
/** The `code` of a 400 naming the fields whose validator refused the value. */
|
|
@@ -160,7 +188,7 @@ export declare namespace Validation {
|
|
|
160
188
|
* other action, it is missing when absent from the body. The body of the
|
|
161
189
|
* 400 is a {@link FieldsErrorBody} with {@link MISSING_MANDATORY_FIELDS}.
|
|
162
190
|
*/
|
|
163
|
-
function MandatoryFields(meta: DataAPIMeta, obj:
|
|
191
|
+
function MandatoryFields(meta: DataAPIMeta, obj: RequestBody, type: string): void;
|
|
164
192
|
/**
|
|
165
193
|
* Runs the validator of each field present in `obj` and rejects with 400
|
|
166
194
|
* when one fails, with a {@link FieldsErrorBody} of
|
|
@@ -185,8 +213,8 @@ export declare namespace Validation {
|
|
|
185
213
|
* untouched keeps its stored locked value: read while locked it would be
|
|
186
214
|
* `undefined`, and locking it again would store that over it.
|
|
187
215
|
*/
|
|
188
|
-
function Lock(obj:
|
|
189
|
-
function Unlock(obj:
|
|
190
|
-
function UnlockRequest<T extends {}, K extends keyof T>(obj:
|
|
191
|
-
function ClearInternal(meta: DataAPIMeta, obj:
|
|
216
|
+
function Lock(obj: DataControllerInstance, meta: DataAPIMeta, data: RowFields): void;
|
|
217
|
+
function Unlock(obj: DataControllerInstance, meta: DataAPIMeta, dbData: RowFields): void;
|
|
218
|
+
function UnlockRequest<T extends {}, K extends keyof T>(obj: DataControllerInstance, meta: DataAPIMeta, row: ValueProxy<T>, field: K): ValueProxy<T[K]>;
|
|
219
|
+
function ClearInternal(meta: DataAPIMeta, obj: RowFields | RowFields[]): void;
|
|
192
220
|
}
|