@atscript/db-client 0.1.170 → 0.1.171
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/index.cjs +33 -1
- package/dist/index.d.cts +33 -1
- package/dist/index.d.mts +33 -1
- package/dist/index.mjs +33 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -130,6 +130,38 @@ function clearMetaStore() {
|
|
|
130
130
|
}
|
|
131
131
|
//#endregion
|
|
132
132
|
//#region src/client.ts
|
|
133
|
+
/**
|
|
134
|
+
* HTTP client for moost-db REST endpoints.
|
|
135
|
+
*
|
|
136
|
+
* Each method maps 1:1 to a controller endpoint:
|
|
137
|
+
* - `query()` → `GET /query`
|
|
138
|
+
* - `count()` → `GET /query` with `$count`
|
|
139
|
+
* - `aggregate()` → `GET /query` with `$groupBy`
|
|
140
|
+
* - `pages()` → `GET /pages`
|
|
141
|
+
* - `one()` → `GET /one/:id` or `GET /one?compositeKeys`
|
|
142
|
+
* - `insert()` → `POST /`
|
|
143
|
+
* - `update()` → `PATCH /`
|
|
144
|
+
* - `replace()` → `PUT /`
|
|
145
|
+
* - `remove()` → `DELETE /:id` or `DELETE /?compositeKeys`
|
|
146
|
+
* - `meta()` → `GET /meta`
|
|
147
|
+
*
|
|
148
|
+
* ```typescript
|
|
149
|
+
* const users = new Client<typeof User>('/api/users')
|
|
150
|
+
* const all = await users.query()
|
|
151
|
+
* const page = await users.pages({ filter: { active: true } }, 1, 20)
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* `D` (since 0.1.148) types the display-only fields the controller declares
|
|
155
|
+
* with `@DbDecorations`: `$select` of the read methods accepts their keys and
|
|
156
|
+
* rows carry them as optional properties. Filter and sort stay over `T`'s own
|
|
157
|
+
* fields — a decoration is never filterable or sortable.
|
|
158
|
+
*
|
|
159
|
+
* ```typescript
|
|
160
|
+
* const tickets = new Client<typeof Ticket, TicketDecorations>('/api/tickets')
|
|
161
|
+
* const rows = await tickets.query({ controls: { $select: ['title', 'ownerName'] } })
|
|
162
|
+
* rows[0].ownerName // string | undefined
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
133
165
|
var Client = class {
|
|
134
166
|
_path;
|
|
135
167
|
_baseUrl;
|
|
@@ -146,7 +178,7 @@ var Client = class {
|
|
|
146
178
|
/** The `ETag` of the `/meta` body {@link _metaPromise} resolved to. */
|
|
147
179
|
_metaEtag;
|
|
148
180
|
_validatorPromise;
|
|
149
|
-
/**
|
|
181
|
+
/** Loaded action forms (type + served `$i18n`) keyed by resolved URL. */
|
|
150
182
|
_formCache = /* @__PURE__ */ new Map();
|
|
151
183
|
constructor(path, opts) {
|
|
152
184
|
this._path = path.endsWith("/") ? path.slice(0, -1) : path;
|
package/dist/index.d.cts
CHANGED
|
@@ -29,6 +29,38 @@ type NestedShape = {
|
|
|
29
29
|
type AggregateCheck<T, Q> = Q extends NestedShape ? ValidNested$1<T, Q> : ValidGroupBy$1<T, Q>;
|
|
30
30
|
/** The rows `aggregate()` answers for query `Q`. */
|
|
31
31
|
type AggregateRows<T, Q extends AggregateQuery$1<T> | NestedAggregateQuery$1<T>> = Q extends NestedShape ? NestedAggregateResult$1<T, Q>[] : Q["controls"]["$select"] extends readonly (string | ComputedExpr)[] ? AggregateResult$1<T, Q["controls"]["$select"]>[] : Record<string, unknown>[];
|
|
32
|
+
/**
|
|
33
|
+
* HTTP client for moost-db REST endpoints.
|
|
34
|
+
*
|
|
35
|
+
* Each method maps 1:1 to a controller endpoint:
|
|
36
|
+
* - `query()` → `GET /query`
|
|
37
|
+
* - `count()` → `GET /query` with `$count`
|
|
38
|
+
* - `aggregate()` → `GET /query` with `$groupBy`
|
|
39
|
+
* - `pages()` → `GET /pages`
|
|
40
|
+
* - `one()` → `GET /one/:id` or `GET /one?compositeKeys`
|
|
41
|
+
* - `insert()` → `POST /`
|
|
42
|
+
* - `update()` → `PATCH /`
|
|
43
|
+
* - `replace()` → `PUT /`
|
|
44
|
+
* - `remove()` → `DELETE /:id` or `DELETE /?compositeKeys`
|
|
45
|
+
* - `meta()` → `GET /meta`
|
|
46
|
+
*
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const users = new Client<typeof User>('/api/users')
|
|
49
|
+
* const all = await users.query()
|
|
50
|
+
* const page = await users.pages({ filter: { active: true } }, 1, 20)
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* `D` (since 0.1.148) types the display-only fields the controller declares
|
|
54
|
+
* with `@DbDecorations`: `$select` of the read methods accepts their keys and
|
|
55
|
+
* rows carry them as optional properties. Filter and sort stay over `T`'s own
|
|
56
|
+
* fields — a decoration is never filterable or sortable.
|
|
57
|
+
*
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const tickets = new Client<typeof Ticket, TicketDecorations>('/api/tickets')
|
|
60
|
+
* const rows = await tickets.query({ controls: { $select: ['title', 'ownerName'] } })
|
|
61
|
+
* rows[0].ownerName // string | undefined
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
32
64
|
declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D extends object = Record<never, never>> {
|
|
33
65
|
private readonly _path;
|
|
34
66
|
private readonly _baseUrl;
|
|
@@ -45,7 +77,7 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
45
77
|
/** The `ETag` of the `/meta` body {@link _metaPromise} resolved to. */
|
|
46
78
|
private _metaEtag?;
|
|
47
79
|
private _validatorPromise?;
|
|
48
|
-
/**
|
|
80
|
+
/** Loaded action forms (type + served `$i18n`) keyed by resolved URL. */
|
|
49
81
|
private _formCache;
|
|
50
82
|
constructor(path: string, opts?: ClientOptions);
|
|
51
83
|
/**
|
package/dist/index.d.mts
CHANGED
|
@@ -29,6 +29,38 @@ type NestedShape = {
|
|
|
29
29
|
type AggregateCheck<T, Q> = Q extends NestedShape ? ValidNested$1<T, Q> : ValidGroupBy$1<T, Q>;
|
|
30
30
|
/** The rows `aggregate()` answers for query `Q`. */
|
|
31
31
|
type AggregateRows<T, Q extends AggregateQuery$1<T> | NestedAggregateQuery$1<T>> = Q extends NestedShape ? NestedAggregateResult$1<T, Q>[] : Q["controls"]["$select"] extends readonly (string | ComputedExpr)[] ? AggregateResult$1<T, Q["controls"]["$select"]>[] : Record<string, unknown>[];
|
|
32
|
+
/**
|
|
33
|
+
* HTTP client for moost-db REST endpoints.
|
|
34
|
+
*
|
|
35
|
+
* Each method maps 1:1 to a controller endpoint:
|
|
36
|
+
* - `query()` → `GET /query`
|
|
37
|
+
* - `count()` → `GET /query` with `$count`
|
|
38
|
+
* - `aggregate()` → `GET /query` with `$groupBy`
|
|
39
|
+
* - `pages()` → `GET /pages`
|
|
40
|
+
* - `one()` → `GET /one/:id` or `GET /one?compositeKeys`
|
|
41
|
+
* - `insert()` → `POST /`
|
|
42
|
+
* - `update()` → `PATCH /`
|
|
43
|
+
* - `replace()` → `PUT /`
|
|
44
|
+
* - `remove()` → `DELETE /:id` or `DELETE /?compositeKeys`
|
|
45
|
+
* - `meta()` → `GET /meta`
|
|
46
|
+
*
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const users = new Client<typeof User>('/api/users')
|
|
49
|
+
* const all = await users.query()
|
|
50
|
+
* const page = await users.pages({ filter: { active: true } }, 1, 20)
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* `D` (since 0.1.148) types the display-only fields the controller declares
|
|
54
|
+
* with `@DbDecorations`: `$select` of the read methods accepts their keys and
|
|
55
|
+
* rows carry them as optional properties. Filter and sort stay over `T`'s own
|
|
56
|
+
* fields — a decoration is never filterable or sortable.
|
|
57
|
+
*
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const tickets = new Client<typeof Ticket, TicketDecorations>('/api/tickets')
|
|
60
|
+
* const rows = await tickets.query({ controls: { $select: ['title', 'ownerName'] } })
|
|
61
|
+
* rows[0].ownerName // string | undefined
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
32
64
|
declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D extends object = Record<never, never>> {
|
|
33
65
|
private readonly _path;
|
|
34
66
|
private readonly _baseUrl;
|
|
@@ -45,7 +77,7 @@ declare class Client<T extends AtscriptClientShape = AtscriptClientShape, D exte
|
|
|
45
77
|
/** The `ETag` of the `/meta` body {@link _metaPromise} resolved to. */
|
|
46
78
|
private _metaEtag?;
|
|
47
79
|
private _validatorPromise?;
|
|
48
|
-
/**
|
|
80
|
+
/** Loaded action forms (type + served `$i18n`) keyed by resolved URL. */
|
|
49
81
|
private _formCache;
|
|
50
82
|
constructor(path: string, opts?: ClientOptions);
|
|
51
83
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -129,6 +129,38 @@ function clearMetaStore() {
|
|
|
129
129
|
}
|
|
130
130
|
//#endregion
|
|
131
131
|
//#region src/client.ts
|
|
132
|
+
/**
|
|
133
|
+
* HTTP client for moost-db REST endpoints.
|
|
134
|
+
*
|
|
135
|
+
* Each method maps 1:1 to a controller endpoint:
|
|
136
|
+
* - `query()` → `GET /query`
|
|
137
|
+
* - `count()` → `GET /query` with `$count`
|
|
138
|
+
* - `aggregate()` → `GET /query` with `$groupBy`
|
|
139
|
+
* - `pages()` → `GET /pages`
|
|
140
|
+
* - `one()` → `GET /one/:id` or `GET /one?compositeKeys`
|
|
141
|
+
* - `insert()` → `POST /`
|
|
142
|
+
* - `update()` → `PATCH /`
|
|
143
|
+
* - `replace()` → `PUT /`
|
|
144
|
+
* - `remove()` → `DELETE /:id` or `DELETE /?compositeKeys`
|
|
145
|
+
* - `meta()` → `GET /meta`
|
|
146
|
+
*
|
|
147
|
+
* ```typescript
|
|
148
|
+
* const users = new Client<typeof User>('/api/users')
|
|
149
|
+
* const all = await users.query()
|
|
150
|
+
* const page = await users.pages({ filter: { active: true } }, 1, 20)
|
|
151
|
+
* ```
|
|
152
|
+
*
|
|
153
|
+
* `D` (since 0.1.148) types the display-only fields the controller declares
|
|
154
|
+
* with `@DbDecorations`: `$select` of the read methods accepts their keys and
|
|
155
|
+
* rows carry them as optional properties. Filter and sort stay over `T`'s own
|
|
156
|
+
* fields — a decoration is never filterable or sortable.
|
|
157
|
+
*
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const tickets = new Client<typeof Ticket, TicketDecorations>('/api/tickets')
|
|
160
|
+
* const rows = await tickets.query({ controls: { $select: ['title', 'ownerName'] } })
|
|
161
|
+
* rows[0].ownerName // string | undefined
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
132
164
|
var Client = class {
|
|
133
165
|
_path;
|
|
134
166
|
_baseUrl;
|
|
@@ -145,7 +177,7 @@ var Client = class {
|
|
|
145
177
|
/** The `ETag` of the `/meta` body {@link _metaPromise} resolved to. */
|
|
146
178
|
_metaEtag;
|
|
147
179
|
_validatorPromise;
|
|
148
|
-
/**
|
|
180
|
+
/** Loaded action forms (type + served `$i18n`) keyed by resolved URL. */
|
|
149
181
|
_formCache = /* @__PURE__ */ new Map();
|
|
150
182
|
constructor(path, opts) {
|
|
151
183
|
this._path = path.endsWith("/") ? path.slice(0, -1) : path;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/db-client",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.171",
|
|
4
4
|
"description": "Browser-compatible HTTP client for @atscript/moost-db REST endpoints.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"atscript",
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"@uniqu/url": "^0.2.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@atscript/core": "^0.2.
|
|
51
|
-
"@atscript/typescript": "^0.2.
|
|
52
|
-
"unplugin-atscript": "^0.2.
|
|
53
|
-
"@atscript/db": "0.1.
|
|
50
|
+
"@atscript/core": "^0.2.8",
|
|
51
|
+
"@atscript/typescript": "^0.2.8",
|
|
52
|
+
"unplugin-atscript": "^0.2.8",
|
|
53
|
+
"@atscript/db": "0.1.171"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@atscript/typescript": "^0.2.
|
|
57
|
-
"@atscript/db": "^0.1.
|
|
56
|
+
"@atscript/typescript": "^0.2.8",
|
|
57
|
+
"@atscript/db": "^0.1.171"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "vp pack",
|