@antelopejs/interface-data-api 0.1.9 → 0.1.10
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/antelope.test.js +4 -3
- package/dist/antelope.test.js.map +1 -1
- package/dist/components.d.ts +2 -2
- package/dist/components.js +7 -7
- package/dist/components.js.map +1 -1
- package/dist/index.d.ts +13 -31
- package/dist/index.js +12 -14
- package/dist/index.js.map +1 -1
- package/dist/metadata.d.ts +20 -3
- package/dist/metadata.js +5 -1
- package/dist/metadata.js.map +1 -1
- package/dist/tests/components/access_control.test.js +2 -2
- package/dist/tests/components/access_control.test.js.map +1 -1
- package/dist/tests/components/computed.test.js +2 -2
- package/dist/tests/components/computed.test.js.map +1 -1
- package/dist/tests/components/deferred_joined.test.js +3 -3
- package/dist/tests/components/deferred_joined.test.js.map +1 -1
- package/dist/tests/components/filter_options.test.js +1 -1
- package/dist/tests/components/filter_options.test.js.map +1 -1
- package/dist/tests/components/foreign_joined.test.js +2 -2
- package/dist/tests/components/foreign_joined.test.js.map +1 -1
- package/dist/tests/components/joined.test.js +3 -3
- package/dist/tests/components/joined.test.js.map +1 -1
- package/dist/tests/components/listable.test.js +2 -2
- package/dist/tests/components/listable.test.js.map +1 -1
- package/dist/tests/components/mandatory.test.js +2 -2
- package/dist/tests/components/mandatory.test.js.map +1 -1
- package/dist/tests/components/modifier_key.test.js +2 -2
- package/dist/tests/components/modifier_key.test.js.map +1 -1
- package/dist/tests/components/per_action_access.test.js +1 -1
- package/dist/tests/components/per_action_access.test.js.map +1 -1
- package/dist/tests/components/validator.test.js +1 -1
- package/dist/tests/components/validator.test.js.map +1 -1
- package/dist/tests/index/get_guard.test.js +2 -2
- package/dist/tests/index/get_guard.test.js.map +1 -1
- package/dist/tests/index/routes.test.js +2 -2
- package/dist/tests/index/routes.test.js.map +1 -1
- package/dist/tests/integration.test.js +1 -1
- package/dist/tests/integration.test.js.map +1 -1
- package/dist/tests/utils.d.ts +7 -0
- package/dist/tests/utils.js +48 -6
- package/dist/tests/utils.js.map +1 -1
- package/dist/tests/utils.test.d.ts +1 -0
- package/dist/tests/utils.test.js +28 -0
- package/dist/tests/utils.test.js.map +1 -0
- package/docs/1.introduction.md +7 -7
- package/docs/10.joined.md +13 -13
- package/docs/11.computed.md +11 -15
- package/docs/2.data-controllers.md +4 -4
- package/docs/3.routes.md +48 -48
- package/docs/4.access-rights.md +5 -5
- package/docs/6.listable.md +7 -7
- package/docs/7.foreign-keys.md +7 -7
- package/docs/8.filters.md +16 -16
- package/docs/9.modifiers.md +2 -2
- package/package.json +44 -36
- package/skills/data-api-interface/SKILL.md +51 -7
package/docs/11.computed.md
CHANGED
|
@@ -54,11 +54,7 @@ class GroupAPI extends DataController(
|
|
|
54
54
|
// Aggregate: number of devices referencing this group, computed in DB
|
|
55
55
|
@Listable()
|
|
56
56
|
@Computed(
|
|
57
|
-
(row, db) =>
|
|
58
|
-
db
|
|
59
|
-
.table("devices")
|
|
60
|
-
.getAll(row.key("_id"), "group_id")
|
|
61
|
-
.count(),
|
|
57
|
+
(row, db) => db.table("devices").getAll(row.key("_id"), "group_id").count(),
|
|
62
58
|
{ default: 0 },
|
|
63
59
|
)
|
|
64
60
|
@Sortable()
|
|
@@ -88,10 +84,10 @@ A GET request to `/groups/get?id=group-123` returns the computed values at the t
|
|
|
88
84
|
@Computed(expr, options?)
|
|
89
85
|
```
|
|
90
86
|
|
|
91
|
-
| Parameter
|
|
92
|
-
|
|
|
93
|
-
| `expr`
|
|
94
|
-
| `options.default` | `unknown`
|
|
87
|
+
| Parameter | Type | Required | Description |
|
|
88
|
+
| ----------------- | ------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
89
|
+
| `expr` | `(row, db) => expression` | Yes | Expression receiving the row proxy and the schema instance; returns a `ValueProxy` expression or a subquery (`Datum`) |
|
|
90
|
+
| `options.default` | `unknown` | No | Fallback merged over the computed value when the expression yields `null` |
|
|
95
91
|
|
|
96
92
|
### The `default` option
|
|
97
93
|
|
|
@@ -134,12 +130,12 @@ declare devices_count: number;
|
|
|
134
130
|
|
|
135
131
|
## Computed vs. Joined
|
|
136
132
|
|
|
137
|
-
| Aspect
|
|
138
|
-
|
|
|
139
|
-
| Source
|
|
140
|
-
| Typical use
|
|
141
|
-
| Access
|
|
142
|
-
| Sort / filter | Native, lazily injected only where needed
|
|
133
|
+
| Aspect | `@Computed` | `@Joined` |
|
|
134
|
+
| ------------- | --------------------------------------------------------------- | ------------------------------------------------------------ |
|
|
135
|
+
| Source | Arbitrary expression: row-local computation or per-row subquery | One scalar field from another table matched by a foreign key |
|
|
136
|
+
| Typical use | Aggregates (`count`, `sum`), derived values | Flattening a referenced record's field |
|
|
137
|
+
| Access | Read-only (enforced) | Read-only (enforced) |
|
|
138
|
+
| Sort / filter | Native, lazily injected only where needed | Native, always applied before sort/filter |
|
|
143
139
|
|
|
144
140
|
`@Joined` remains the simpler choice for the 1:1 flattening case; `@Computed` generalizes the same merge mechanism to arbitrary expressions.
|
|
145
141
|
|
|
@@ -81,11 +81,11 @@ DataController(
|
|
|
81
81
|
)
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
| Parameter
|
|
85
|
-
|
|
|
84
|
+
| Parameter | Description |
|
|
85
|
+
| ------------ | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
86
86
|
| `tableClass` | The database table class decorated with `@RegisterTable`. The controller validates that this table exists in the database schema. |
|
|
87
|
-
| `routes`
|
|
88
|
-
| `base`
|
|
87
|
+
| `routes` | An object mapping endpoint names to route callbacks. Use `DefaultRoutes.All` for standard CRUD or pass a custom subset. |
|
|
88
|
+
| `base` | The controller base, typically created with `Controller("/path")`, which sets the URL prefix for all endpoints. |
|
|
89
89
|
|
|
90
90
|
## Required Components
|
|
91
91
|
|
package/docs/3.routes.md
CHANGED
|
@@ -12,13 +12,13 @@ The `DefaultRoutes` namespace provides five built-in routes covering standard CR
|
|
|
12
12
|
import { DefaultRoutes } from "@antelopejs/interface-data-api";
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
| Route
|
|
16
|
-
|
|
|
17
|
-
| Get
|
|
18
|
-
| List
|
|
19
|
-
| New
|
|
20
|
-
| Edit
|
|
21
|
-
| Delete | `DefaultRoutes.Delete` | DELETE
|
|
15
|
+
| Route | Object | HTTP Method | Endpoint Pattern |
|
|
16
|
+
| ------ | ---------------------- | ----------- | -------------------------- |
|
|
17
|
+
| Get | `DefaultRoutes.Get` | GET | `/resource/get?id=<id>` |
|
|
18
|
+
| List | `DefaultRoutes.List` | GET | `/resource/list` |
|
|
19
|
+
| New | `DefaultRoutes.New` | POST | `/resource/new` |
|
|
20
|
+
| Edit | `DefaultRoutes.Edit` | PUT | `/resource/edit?id=<id>` |
|
|
21
|
+
| Delete | `DefaultRoutes.Delete` | DELETE | `/resource/delete?id=<id>` |
|
|
22
22
|
|
|
23
23
|
Use `DefaultRoutes.All` to include all five routes at once.
|
|
24
24
|
|
|
@@ -62,9 +62,9 @@ Retrieves a single record by its identifier.
|
|
|
62
62
|
|
|
63
63
|
**Query Parameters:**
|
|
64
64
|
|
|
65
|
-
| Parameter | Required | Description
|
|
66
|
-
| --------- | -------- |
|
|
67
|
-
| `id`
|
|
65
|
+
| Parameter | Required | Description |
|
|
66
|
+
| --------- | -------- | ----------------- |
|
|
67
|
+
| `id` | Yes | Record identifier |
|
|
68
68
|
|
|
69
69
|
**Example:**
|
|
70
70
|
|
|
@@ -90,12 +90,12 @@ Retrieves multiple records with pagination, sorting, and filtering support.
|
|
|
90
90
|
|
|
91
91
|
**Query Parameters:**
|
|
92
92
|
|
|
93
|
-
| Parameter
|
|
94
|
-
|
|
|
95
|
-
| `limit`
|
|
96
|
-
| `offset`
|
|
97
|
-
| `sortKey`
|
|
98
|
-
| `sortDirection` | No
|
|
93
|
+
| Parameter | Required | Default | Description |
|
|
94
|
+
| --------------- | -------- | ------- | --------------------------------------------- |
|
|
95
|
+
| `limit` | No | `10` | Maximum number of records to return |
|
|
96
|
+
| `offset` | No | `0` | Number of records to skip |
|
|
97
|
+
| `sortKey` | No | - | Field to sort by (must be marked `@Sortable`) |
|
|
98
|
+
| `sortDirection` | No | `asc` | Sort direction: `asc` or `desc` |
|
|
99
99
|
|
|
100
100
|
**Example:**
|
|
101
101
|
|
|
@@ -154,9 +154,9 @@ Updates an existing record by its identifier.
|
|
|
154
154
|
|
|
155
155
|
**Query Parameters:**
|
|
156
156
|
|
|
157
|
-
| Parameter | Required | Description
|
|
158
|
-
| --------- | -------- |
|
|
159
|
-
| `id`
|
|
157
|
+
| Parameter | Required | Description |
|
|
158
|
+
| --------- | -------- | ----------------- |
|
|
159
|
+
| `id` | Yes | Record identifier |
|
|
160
160
|
|
|
161
161
|
**Body:** JSON object with fields to update.
|
|
162
162
|
|
|
@@ -188,9 +188,9 @@ Deletes one or more records by their identifiers.
|
|
|
188
188
|
|
|
189
189
|
**Query Parameters:**
|
|
190
190
|
|
|
191
|
-
| Parameter | Required | Description
|
|
192
|
-
| --------- | -------- |
|
|
193
|
-
| `id`
|
|
191
|
+
| Parameter | Required | Description |
|
|
192
|
+
| --------- | -------- | -------------------------------------------------------------------------------------- |
|
|
193
|
+
| `id` | Yes | Record identifier(s). Pass multiple `id` parameters to delete several records at once. |
|
|
194
194
|
|
|
195
195
|
**Example:**
|
|
196
196
|
|
|
@@ -212,11 +212,11 @@ The `DefaultRoutes.WithOptions` function customizes route behavior by overriding
|
|
|
212
212
|
DefaultRoutes.WithOptions(callback, options?, endpoint?)
|
|
213
213
|
```
|
|
214
214
|
|
|
215
|
-
| Parameter
|
|
216
|
-
|
|
|
217
|
-
| `callback` | The route callback to customize (e.g., `DefaultRoutes.Edit`).
|
|
218
|
-
| `options`
|
|
219
|
-
| `endpoint` | An optional custom endpoint path. Defaults to the route key name.
|
|
215
|
+
| Parameter | Description |
|
|
216
|
+
| ---------- | ------------------------------------------------------------------------------------ |
|
|
217
|
+
| `callback` | The route callback to customize (e.g., `DefaultRoutes.Edit`). |
|
|
218
|
+
| `options` | An object with option overrides. These values take precedence over query parameters. |
|
|
219
|
+
| `endpoint` | An optional custom endpoint path. Defaults to the route key name. |
|
|
220
220
|
|
|
221
221
|
### Example
|
|
222
222
|
|
|
@@ -239,32 +239,32 @@ class UserAPI extends DataController(User, routes, Controller("/users")) {
|
|
|
239
239
|
|
|
240
240
|
**Get:**
|
|
241
241
|
|
|
242
|
-
| Option
|
|
243
|
-
|
|
|
244
|
-
| `index`
|
|
245
|
-
| `noForeign` | `string` | Skip foreign key resolution
|
|
242
|
+
| Option | Type | Description |
|
|
243
|
+
| ----------- | -------- | ------------------------------------------------ |
|
|
244
|
+
| `index` | `string` | Use a secondary index instead of the primary key |
|
|
245
|
+
| `noForeign` | `string` | Skip foreign key resolution |
|
|
246
246
|
|
|
247
247
|
**List:**
|
|
248
248
|
|
|
249
|
-
| Option
|
|
250
|
-
|
|
|
251
|
-
| `maxPage`
|
|
252
|
-
| `noForeign` | `boolean` | Skip foreign key resolution
|
|
253
|
-
| `noPluck`
|
|
254
|
-
| `pluckMode` | `string`
|
|
249
|
+
| Option | Type | Description |
|
|
250
|
+
| ----------- | --------- | ------------------------------------------------------ |
|
|
251
|
+
| `maxPage` | `number` | Maximum allowed value for `limit` (caps the page size) |
|
|
252
|
+
| `noForeign` | `boolean` | Skip foreign key resolution |
|
|
253
|
+
| `noPluck` | `boolean` | Return all database fields instead of plucked fields |
|
|
254
|
+
| `pluckMode` | `string` | Select a named pluck mode (see `@Listable`) |
|
|
255
255
|
|
|
256
256
|
**New:**
|
|
257
257
|
|
|
258
|
-
| Option
|
|
259
|
-
|
|
|
258
|
+
| Option | Type | Description |
|
|
259
|
+
| ------------- | -------- | ------------------------------- |
|
|
260
260
|
| `noMandatory` | `string` | Skip mandatory field validation |
|
|
261
261
|
|
|
262
262
|
**Edit:**
|
|
263
263
|
|
|
264
|
-
| Option
|
|
265
|
-
|
|
|
266
|
-
| `index`
|
|
267
|
-
| `noMandatory` | `string` | Skip mandatory field validation
|
|
264
|
+
| Option | Type | Description |
|
|
265
|
+
| ------------- | -------- | ------------------------------------------------ |
|
|
266
|
+
| `index` | `string` | Use a secondary index instead of the primary key |
|
|
267
|
+
| `noMandatory` | `string` | Skip mandatory field validation |
|
|
268
268
|
|
|
269
269
|
## Custom Routes
|
|
270
270
|
|
|
@@ -307,11 +307,11 @@ The `args` array contains parameter decorators that extract values from the requ
|
|
|
307
307
|
|
|
308
308
|
Default routes return standard HTTP error responses:
|
|
309
309
|
|
|
310
|
-
| Status
|
|
311
|
-
|
|
|
312
|
-
| `400 Bad Request`
|
|
313
|
-
| `404 Not Found`
|
|
314
|
-
| `500 Internal Server Error` | Database operation fails
|
|
310
|
+
| Status | Condition |
|
|
311
|
+
| --------------------------- | ---------------------------------------------------------------- |
|
|
312
|
+
| `400 Bad Request` | Validation fails, missing required fields, or invalid parameters |
|
|
313
|
+
| `404 Not Found` | Record does not exist |
|
|
314
|
+
| `500 Internal Server Error` | Database operation fails |
|
|
315
315
|
|
|
316
316
|
Error messages are returned as plain text in the response body.
|
|
317
317
|
|
package/docs/4.access-rights.md
CHANGED
|
@@ -12,11 +12,11 @@ The `AccessMode` enum defines three permission levels:
|
|
|
12
12
|
import { Access, AccessMode } from "@antelopejs/interface-data-api/metadata";
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
| Mode
|
|
16
|
-
|
|
|
17
|
-
| `AccessMode.ReadOnly`
|
|
18
|
-
| `AccessMode.WriteOnly` | `2`
|
|
19
|
-
| `AccessMode.ReadWrite` | `3`
|
|
15
|
+
| Mode | Value | Description |
|
|
16
|
+
| ---------------------- | ----- | ----------------------------------------------------------------------------- |
|
|
17
|
+
| `AccessMode.ReadOnly` | `1` | Field appears in GET and LIST responses but is ignored in POST and PUT bodies |
|
|
18
|
+
| `AccessMode.WriteOnly` | `2` | Field is accepted in POST and PUT bodies but never appears in responses |
|
|
19
|
+
| `AccessMode.ReadWrite` | `3` | Field is both readable and writable |
|
|
20
20
|
|
|
21
21
|
## Basic Usage
|
|
22
22
|
|
package/docs/6.listable.md
CHANGED
|
@@ -140,10 +140,10 @@ List responses include pagination metadata. The response structure is:
|
|
|
140
140
|
|
|
141
141
|
### Query Parameters
|
|
142
142
|
|
|
143
|
-
| Parameter | Default | Description
|
|
144
|
-
| --------- | ------- |
|
|
145
|
-
| `limit`
|
|
146
|
-
| `offset`
|
|
143
|
+
| Parameter | Default | Description |
|
|
144
|
+
| --------- | ------- | ----------------------------------- |
|
|
145
|
+
| `limit` | `10` | Maximum number of records to return |
|
|
146
|
+
| `offset` | `0` | Number of records to skip |
|
|
147
147
|
|
|
148
148
|
### Example
|
|
149
149
|
|
|
@@ -214,9 +214,9 @@ class UserAPI extends DataController(
|
|
|
214
214
|
|
|
215
215
|
### Sort Query Parameters
|
|
216
216
|
|
|
217
|
-
| Parameter
|
|
218
|
-
|
|
|
219
|
-
| `sortKey`
|
|
217
|
+
| Parameter | Description |
|
|
218
|
+
| --------------- | ------------------------------------------------------------------ |
|
|
219
|
+
| `sortKey` | The field name to sort by. Must be decorated with `@Sortable`. |
|
|
220
220
|
| `sortDirection` | `"asc"` (ascending) or `"desc"` (descending). Defaults to `"asc"`. |
|
|
221
221
|
|
|
222
222
|
### The `noIndex` Option
|
package/docs/7.foreign-keys.md
CHANGED
|
@@ -90,13 +90,13 @@ A GET request to `/orders/get?id=order-123` returns the full user object instead
|
|
|
90
90
|
@Foreign(table, index?, multi?, pluck?, schema?)
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
| Parameter | Type
|
|
94
|
-
| --------- |
|
|
95
|
-
| `table`
|
|
96
|
-
| `index`
|
|
97
|
-
| `multi`
|
|
98
|
-
| `pluck`
|
|
99
|
-
| `schema`
|
|
93
|
+
| Parameter | Type | Required | Default | Description |
|
|
94
|
+
| --------- | -------------------------- | -------- | ----------------- | -------------------------------------------------------------------------------------------------- |
|
|
95
|
+
| `table` | `Class<Table>` or `string` | Yes | - | The target table class or table name string |
|
|
96
|
+
| `index` | `string` | No | `"_id"` | The index on the target table to match against |
|
|
97
|
+
| `multi` | `boolean` | No | `false` | Set to `true` when the field holds an array of foreign keys |
|
|
98
|
+
| `pluck` | `string[]` | No | All fields | List of fields to include from the referenced record |
|
|
99
|
+
| `schema` | `string` | No | Controller schema | Name of the schema the target table is registered in, when it differs from the controller's schema |
|
|
100
100
|
|
|
101
101
|
## Table Reference Methods
|
|
102
102
|
|
package/docs/8.filters.md
CHANGED
|
@@ -52,14 +52,14 @@ When no operator is specified, `eq` (equal) is used by default.
|
|
|
52
52
|
|
|
53
53
|
### Comparison Operators
|
|
54
54
|
|
|
55
|
-
| Operator | Description
|
|
56
|
-
| -------- |
|
|
57
|
-
| `eq`
|
|
58
|
-
| `ne`
|
|
59
|
-
| `gt`
|
|
60
|
-
| `ge`
|
|
61
|
-
| `lt`
|
|
62
|
-
| `le`
|
|
55
|
+
| Operator | Description |
|
|
56
|
+
| -------- | ------------------------ |
|
|
57
|
+
| `eq` | Equal to (default) |
|
|
58
|
+
| `ne` | Not equal to |
|
|
59
|
+
| `gt` | Greater than |
|
|
60
|
+
| `ge` | Greater than or equal to |
|
|
61
|
+
| `lt` | Less than |
|
|
62
|
+
| `le` | Less than or equal to |
|
|
63
63
|
|
|
64
64
|
### Examples
|
|
65
65
|
|
|
@@ -98,14 +98,14 @@ type FilterFunction<T, U> = (
|
|
|
98
98
|
) => ValueProxyOrValue<boolean>;
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
| Parameter | Description
|
|
102
|
-
| --------- |
|
|
103
|
-
| `context` | The request context, extended with `this` referencing the controller instance
|
|
104
|
-
| `proxy`
|
|
105
|
-
| `key`
|
|
106
|
-
| `value`
|
|
107
|
-
| `mode`
|
|
108
|
-
| `row`
|
|
101
|
+
| Parameter | Description |
|
|
102
|
+
| --------- | -------------------------------------------------------------------------------------------------------------- |
|
|
103
|
+
| `context` | The request context, extended with `this` referencing the controller instance |
|
|
104
|
+
| `proxy` | A `ValueProxy` representing the field value with modifier transformations applied (e.g., decrypted, localized) |
|
|
105
|
+
| `key` | The field name being filtered |
|
|
106
|
+
| `value` | The filter value from the query parameter |
|
|
107
|
+
| `mode` | The comparison operator from the query parameter |
|
|
108
|
+
| `row` | The full database row as a `ValueProxy` |
|
|
109
109
|
|
|
110
110
|
### Example: Pattern Matching Filter
|
|
111
111
|
|
package/docs/9.modifiers.md
CHANGED
|
@@ -20,8 +20,8 @@ import { ModifierKey } from "@antelopejs/interface-data-api/metadata";
|
|
|
20
20
|
@ModifierKey(modifierClass: typeof ContainerModifier<any>)
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
| Parameter
|
|
24
|
-
|
|
|
23
|
+
| Parameter | Description |
|
|
24
|
+
| --------------- | ----------------------------------------------------------------------------- |
|
|
25
25
|
| `modifierClass` | The modifier class that requires a runtime key (e.g., `LocalizationModifier`) |
|
|
26
26
|
|
|
27
27
|
### Example: Localized Content
|
package/package.json
CHANGED
|
@@ -1,26 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/interface-data-api",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "AntelopeJS interface for data API with CRUD controllers and route generation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
7
|
-
"
|
|
7
|
+
"crud",
|
|
8
8
|
"data-api",
|
|
9
|
-
"
|
|
9
|
+
"interface"
|
|
10
10
|
],
|
|
11
|
+
"license": "Apache-2.0",
|
|
11
12
|
"repository": {
|
|
12
13
|
"type": "git",
|
|
13
14
|
"url": "git+https://github.com/AntelopeJS/interface-data-api.git"
|
|
14
15
|
},
|
|
15
|
-
"license": "Apache-2.0",
|
|
16
|
-
"packageManager": "pnpm@10.6.5",
|
|
17
|
-
"main": "dist/index.js",
|
|
18
|
-
"types": "dist/index.d.ts",
|
|
19
16
|
"files": [
|
|
20
17
|
"dist",
|
|
21
18
|
"docs",
|
|
22
19
|
"skills"
|
|
23
20
|
],
|
|
21
|
+
"main": "dist/index.js",
|
|
22
|
+
"types": "dist/index.d.ts",
|
|
23
|
+
"typesVersions": {
|
|
24
|
+
"*": {
|
|
25
|
+
"components": [
|
|
26
|
+
"dist/components.d.ts"
|
|
27
|
+
],
|
|
28
|
+
"metadata": [
|
|
29
|
+
"dist/metadata.d.ts"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
24
33
|
"exports": {
|
|
25
34
|
".": {
|
|
26
35
|
"types": "./dist/index.d.ts",
|
|
@@ -32,54 +41,53 @@
|
|
|
32
41
|
},
|
|
33
42
|
"./package.json": "./package.json"
|
|
34
43
|
},
|
|
44
|
+
"publishConfig": {
|
|
45
|
+
"access": "public",
|
|
46
|
+
"provenance": true
|
|
47
|
+
},
|
|
35
48
|
"scripts": {
|
|
36
49
|
"build": "rimraf dist && tsc",
|
|
37
|
-
"format": "
|
|
38
|
-
"lint:fix": "
|
|
39
|
-
"lint": "
|
|
50
|
+
"format": "oxfmt .",
|
|
51
|
+
"lint:fix": "oxlint --fix",
|
|
52
|
+
"lint": "oxlint",
|
|
40
53
|
"prepack": "pnpm run build",
|
|
41
54
|
"release": "pnpm run lint && pnpm run prepack && release-it",
|
|
42
|
-
"test": "pnpm run build && ajs module test ."
|
|
55
|
+
"test": "pnpm run build && ajs module test .",
|
|
56
|
+
"format:check": "oxfmt --check .",
|
|
57
|
+
"knip": "knip"
|
|
43
58
|
},
|
|
44
59
|
"devDependencies": {
|
|
45
|
-
"@antelopejs/
|
|
46
|
-
"@antelopejs/interface-api
|
|
47
|
-
"@antelopejs/interface-
|
|
48
|
-
"@antelopejs/interface-
|
|
49
|
-
"@antelopejs/interface-database
|
|
50
|
-
"@
|
|
60
|
+
"@antelopejs/core": "^1.13.4",
|
|
61
|
+
"@antelopejs/interface-api": "^0.0.13",
|
|
62
|
+
"@antelopejs/interface-api-util": "^0.1.2",
|
|
63
|
+
"@antelopejs/interface-core": "^0.1.1",
|
|
64
|
+
"@antelopejs/interface-database": "^0.1.7",
|
|
65
|
+
"@antelopejs/interface-database-decorators": "^0.1.6",
|
|
66
|
+
"@antelopejs/tooling-configs": "^0.0.6",
|
|
51
67
|
"@types/chai": "^4.3.20",
|
|
52
68
|
"@types/mocha": "^10.0.10",
|
|
53
69
|
"@types/node": "^22.19.15",
|
|
54
70
|
"@types/semver": "^7.7.1",
|
|
55
71
|
"chai": "^4.5.0",
|
|
72
|
+
"eslint-plugin-perfectionist": "^5.11.0",
|
|
73
|
+
"knip": "^6.34.0",
|
|
56
74
|
"mongodb-memory-server-core": "^10.4.3",
|
|
75
|
+
"oxfmt": "^0.66.0",
|
|
76
|
+
"oxlint": "1.81.0",
|
|
77
|
+
"oxlint-tsgolint": "^7.0.2001",
|
|
57
78
|
"release-it": "^19.2.4",
|
|
58
79
|
"release-it-changelogen": "^0.1.0",
|
|
59
80
|
"rimraf": "^6.1.3",
|
|
60
81
|
"typescript": "^5.9.3"
|
|
61
82
|
},
|
|
62
83
|
"peerDependencies": {
|
|
63
|
-
"@antelopejs/interface-api": ">=0.0.
|
|
64
|
-
"@antelopejs/interface-api-util": ">=0.
|
|
65
|
-
"@antelopejs/interface-core": ">=0.
|
|
66
|
-
"@antelopejs/interface-database": ">=0.1.
|
|
67
|
-
"@antelopejs/interface-database-decorators": ">=0.1.
|
|
68
|
-
},
|
|
69
|
-
"publishConfig": {
|
|
70
|
-
"access": "public",
|
|
71
|
-
"provenance": true
|
|
72
|
-
},
|
|
73
|
-
"typesVersions": {
|
|
74
|
-
"*": {
|
|
75
|
-
"components": [
|
|
76
|
-
"dist/components.d.ts"
|
|
77
|
-
],
|
|
78
|
-
"metadata": [
|
|
79
|
-
"dist/metadata.d.ts"
|
|
80
|
-
]
|
|
81
|
-
}
|
|
84
|
+
"@antelopejs/interface-api": ">=0.0.13 <1.0.0",
|
|
85
|
+
"@antelopejs/interface-api-util": ">=0.1.2 <1.0.0",
|
|
86
|
+
"@antelopejs/interface-core": ">=0.1.1 <1.0.0",
|
|
87
|
+
"@antelopejs/interface-database": ">=0.1.7 <1.0.0",
|
|
88
|
+
"@antelopejs/interface-database-decorators": ">=0.1.6 <1.0.0"
|
|
82
89
|
},
|
|
90
|
+
"packageManager": "pnpm@10.6.5",
|
|
83
91
|
"antelopeJs": {
|
|
84
92
|
"standalone": true,
|
|
85
93
|
"test": "src/antelope.test.ts",
|
|
@@ -17,9 +17,32 @@ your module must also import those peer interfaces.
|
|
|
17
17
|
## Imports
|
|
18
18
|
|
|
19
19
|
```typescript
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
import {
|
|
21
|
+
DataController,
|
|
22
|
+
DefaultRoutes,
|
|
23
|
+
RegisterDataController,
|
|
24
|
+
GetDataControllerMeta,
|
|
25
|
+
} from "@antelopejs/interface-data-api";
|
|
26
|
+
import {
|
|
27
|
+
Access,
|
|
28
|
+
AccessMode,
|
|
29
|
+
Listable,
|
|
30
|
+
Mandatory,
|
|
31
|
+
Optional,
|
|
32
|
+
Sortable,
|
|
33
|
+
Filter,
|
|
34
|
+
Foreign,
|
|
35
|
+
Joined,
|
|
36
|
+
Computed,
|
|
37
|
+
Validator,
|
|
38
|
+
ModelReference,
|
|
39
|
+
ModifierKey,
|
|
40
|
+
} from "@antelopejs/interface-data-api/metadata";
|
|
41
|
+
import {
|
|
42
|
+
Parameters,
|
|
43
|
+
Query,
|
|
44
|
+
Validation,
|
|
45
|
+
} from "@antelopejs/interface-data-api/components";
|
|
23
46
|
```
|
|
24
47
|
|
|
25
48
|
`/components` is only needed for custom route callbacks (query building, validation helpers).
|
|
@@ -28,9 +51,26 @@ import { Parameters, Query, Validation } from "@antelopejs/interface-data-api/co
|
|
|
28
51
|
|
|
29
52
|
```typescript
|
|
30
53
|
import { Controller } from "@antelopejs/interface-api";
|
|
31
|
-
import {
|
|
32
|
-
|
|
33
|
-
|
|
54
|
+
import {
|
|
55
|
+
DataController,
|
|
56
|
+
DefaultRoutes,
|
|
57
|
+
RegisterDataController,
|
|
58
|
+
} from "@antelopejs/interface-data-api";
|
|
59
|
+
import {
|
|
60
|
+
Access,
|
|
61
|
+
AccessMode,
|
|
62
|
+
Listable,
|
|
63
|
+
Mandatory,
|
|
64
|
+
ModelReference,
|
|
65
|
+
Sortable,
|
|
66
|
+
} from "@antelopejs/interface-data-api/metadata";
|
|
67
|
+
import {
|
|
68
|
+
BasicDataModel,
|
|
69
|
+
Field,
|
|
70
|
+
Model,
|
|
71
|
+
RegisterTable,
|
|
72
|
+
Table,
|
|
73
|
+
} from "@antelopejs/interface-database-decorators";
|
|
34
74
|
|
|
35
75
|
@RegisterTable("tasks", "default")
|
|
36
76
|
class Task extends Table {
|
|
@@ -43,7 +83,11 @@ class Task extends Table {
|
|
|
43
83
|
class TaskModel extends BasicDataModel(Task, "tasks") {}
|
|
44
84
|
|
|
45
85
|
@RegisterDataController()
|
|
46
|
-
class TaskAPI extends DataController(
|
|
86
|
+
class TaskAPI extends DataController(
|
|
87
|
+
Task,
|
|
88
|
+
DefaultRoutes.All,
|
|
89
|
+
Controller("/tasks"),
|
|
90
|
+
) {
|
|
47
91
|
@ModelReference()
|
|
48
92
|
@Model(TaskModel, "my-database")
|
|
49
93
|
declare taskModel: TaskModel;
|