@codyswann/lisa 2.167.0 → 2.169.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/package.json +1 -1
- package/plugins/lisa/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-agy/plugin.json +1 -1
- package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-agy/plugin.json +1 -1
- package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-agy/plugin.json +1 -1
- package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric/skills/harper-operations/SKILL.md +239 -0
- package/plugins/lisa-harper-fabric/skills/harper-operations/agents/openai.yaml +4 -0
- package/plugins/lisa-harper-fabric/skills/harper-rest-queries/SKILL.md +366 -0
- package/plugins/lisa-harper-fabric/skills/harper-rest-queries/agents/openai.yaml +4 -0
- package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-agy/skills/harper-operations/SKILL.md +239 -0
- package/plugins/lisa-harper-fabric-agy/skills/harper-rest-queries/SKILL.md +366 -0
- package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-copilot/skills/harper-operations/SKILL.md +239 -0
- package/plugins/lisa-harper-fabric-copilot/skills/harper-rest-queries/SKILL.md +366 -0
- package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-harper-fabric-cursor/skills/harper-operations/SKILL.md +239 -0
- package/plugins/lisa-harper-fabric-cursor/skills/harper-rest-queries/SKILL.md +366 -0
- package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-agy/plugin.json +1 -1
- package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-agy/plugin.json +1 -1
- package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-agy/plugin.json +1 -1
- package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-agy/plugin.json +1 -1
- package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-agy/plugin.json +1 -1
- package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-agy/plugin.json +1 -1
- package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
- package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
- package/plugins/src/harper-fabric/skills/harper-operations/SKILL.md +239 -0
- package/plugins/src/harper-fabric/skills/harper-rest-queries/SKILL.md +366 -0
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: harper-rest-queries
|
|
3
|
+
description: This skill should be used when building or debugging Harper (HarperDB/Fabric) REST collection queries and Resource search methods - filters, FIQL comparison operators, OR/grouping, select, sort, limit/offset pagination, relationship traversal, request context, and transaction boundaries. Use it when adding list endpoints, admin filters, query builders, or multi-write resource methods. Pairs with harper-resources and harper-schema-graphql.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Harper REST Queries
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Harper exposes exported tables and custom Resources as REST endpoints when
|
|
11
|
+
`rest: true` is enabled. Collection `GET` requests use URL query parameters for
|
|
12
|
+
filtering, sorting, projection, pagination, and relationship traversal. The same
|
|
13
|
+
query shape is available inside Resources through `search(query)` and
|
|
14
|
+
`tables.X.search(query)`.
|
|
15
|
+
|
|
16
|
+
Use Harper's native query surface before hand-filtering records in JavaScript.
|
|
17
|
+
Hand-filtering is only acceptable after a selective indexed condition has already
|
|
18
|
+
narrowed the candidate set and the behavior cannot be represented by the REST
|
|
19
|
+
query language.
|
|
20
|
+
|
|
21
|
+
Cross-check endpoint ownership and generated resource conventions in
|
|
22
|
+
[[harper-resources]]. Cross-check table names, indexes, exported resources, and
|
|
23
|
+
relationships in [[harper-schema-graphql]].
|
|
24
|
+
|
|
25
|
+
## REST collection syntax
|
|
26
|
+
|
|
27
|
+
REST queries run against collection paths with a trailing slash:
|
|
28
|
+
|
|
29
|
+
```text
|
|
30
|
+
GET /products/?category=software
|
|
31
|
+
GET /products/?category=software&active=true
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Rules:
|
|
35
|
+
|
|
36
|
+
- Query attributes that appear in conditions should be indexed with `@indexed`.
|
|
37
|
+
- Multiple `&` conditions are ANDed.
|
|
38
|
+
- `|` combines conditions with OR logic.
|
|
39
|
+
- Use square brackets for grouping generated from user input because they encode
|
|
40
|
+
cleanly in URLs.
|
|
41
|
+
- Encode reserved characters, especially `:` in dates as `%3A`.
|
|
42
|
+
|
|
43
|
+
Common condition examples:
|
|
44
|
+
|
|
45
|
+
```text
|
|
46
|
+
GET /products/?category=software
|
|
47
|
+
GET /products/?price=gt=100
|
|
48
|
+
GET /products/?price=ge=100&price=lt=200
|
|
49
|
+
GET /products/?price=gt=100&price=lt=200
|
|
50
|
+
GET /products/?name==Keyboard*
|
|
51
|
+
GET /products/?rating=5|featured=true
|
|
52
|
+
GET /products/?rating=5&[tag=fast|tag=scalable|tag=efficient]
|
|
53
|
+
GET /products/?discount=null
|
|
54
|
+
GET /products/?listDate=gt=2026-01-05T20%3A07%3A27.955Z
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Operators
|
|
58
|
+
|
|
59
|
+
Harper REST comparison operators use FIQL-style syntax:
|
|
60
|
+
|
|
61
|
+
| URL operator | Programmatic comparator | Meaning |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| `==` | `equals` | Equal with type conversion |
|
|
64
|
+
| `=lt=` / `lt=` | `less_than` | Less than |
|
|
65
|
+
| `=le=` / `le=` | `less_than_equal` | Less than or equal |
|
|
66
|
+
| `=gt=` / `gt=` | `greater_than` | Greater than |
|
|
67
|
+
| `=ge=` / `ge=` | `greater_than_equal` | Greater than or equal |
|
|
68
|
+
| `=ne=` / `!=` | `not_equal` | Not equal |
|
|
69
|
+
| `=ct=` | `contains` | String contains |
|
|
70
|
+
| `=sw=` / `==value*` | `starts_with` | String starts with |
|
|
71
|
+
| `=ew=` | `ends_with` | String ends with |
|
|
72
|
+
| `=` / `===` | strict equality | No automatic URL-value conversion |
|
|
73
|
+
| `!==` | strict inequality | No automatic URL-value conversion |
|
|
74
|
+
|
|
75
|
+
For FIQL comparators, Harper converts strings such as `null`, `true`, numbers,
|
|
76
|
+
and schema-typed values before searching. Use explicit prefixes when a generated
|
|
77
|
+
URL must control conversion:
|
|
78
|
+
|
|
79
|
+
```text
|
|
80
|
+
GET /products/?price==number:123
|
|
81
|
+
GET /products/?active==boolean:true
|
|
82
|
+
GET /products/?sku==string:00123
|
|
83
|
+
GET /products/?createdAt==date:2026-01-05T20%3A07%3A27.955Z
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Select, sort, and pagination
|
|
87
|
+
|
|
88
|
+
Use query functions for projection, paging, and order:
|
|
89
|
+
|
|
90
|
+
```text
|
|
91
|
+
GET /products/?category=software&select(id,name,price)
|
|
92
|
+
GET /products/?category=software&select([id,name])
|
|
93
|
+
GET /products/?category=software&limit(20)
|
|
94
|
+
GET /products/?category=software&limit(40,60)
|
|
95
|
+
GET /products/?category=software&sort(+name)
|
|
96
|
+
GET /products/?category=software&sort(+rating,-price)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Guidance:
|
|
100
|
+
|
|
101
|
+
- `select(property)` returns a single property directly.
|
|
102
|
+
- `select(property1,property2)` returns objects with those properties.
|
|
103
|
+
- `select([property1,property2])` returns arrays of selected property values.
|
|
104
|
+
- `limit(end)` returns the first `end` records.
|
|
105
|
+
- `limit(start,end)` uses `start` as the offset and returns through `end`.
|
|
106
|
+
- Prefix sort fields with `+` for ascending and `-` for descending.
|
|
107
|
+
- Prefer sorting on an indexed field used by the primary condition, or a narrow
|
|
108
|
+
result set that can be sorted cheaply.
|
|
109
|
+
|
|
110
|
+
Programmatic pagination normally uses `limit` and `offset`:
|
|
111
|
+
|
|
112
|
+
```javascript
|
|
113
|
+
const pageSize = 20;
|
|
114
|
+
const page = Number(url.searchParams.get('page') ?? 0);
|
|
115
|
+
|
|
116
|
+
const products = await tables.Products.search({
|
|
117
|
+
conditions: [{ attribute: 'category', value: 'software' }],
|
|
118
|
+
sort: { attribute: 'createdAt', descending: true },
|
|
119
|
+
limit: pageSize,
|
|
120
|
+
offset: page * pageSize,
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Relationship queries
|
|
125
|
+
|
|
126
|
+
Relationship attributes can be queried with dot syntax when the relationship is
|
|
127
|
+
declared in `schema.graphql` and the foreign key fields are indexed:
|
|
128
|
+
|
|
129
|
+
```graphql
|
|
130
|
+
type Product @table @export(name: "products") {
|
|
131
|
+
id: Long @primaryKey
|
|
132
|
+
name: String
|
|
133
|
+
brandId: Long @indexed
|
|
134
|
+
brand: Brand @relationship(from: brandId)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
type Brand @table @export(name: "brands") {
|
|
138
|
+
id: Long @primaryKey
|
|
139
|
+
name: String @indexed
|
|
140
|
+
products: [Product] @relationship(to: brandId)
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
```text
|
|
145
|
+
GET /products/?brand.name=Microsoft
|
|
146
|
+
GET /brands/?products.name=Keyboard
|
|
147
|
+
GET /products/?brand.name=Microsoft&select(id,name,brand{name})
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Filtering on a related table behaves like an inner join. Selecting a relationship
|
|
151
|
+
without filtering can behave like a left join; missing relationships may be
|
|
152
|
+
omitted from returned records. Keep relationship names and directives aligned
|
|
153
|
+
with [[harper-schema-graphql]] before changing a route.
|
|
154
|
+
|
|
155
|
+
## Programmatic search
|
|
156
|
+
|
|
157
|
+
Use `search(query)` inside custom Resources when the endpoint needs validation,
|
|
158
|
+
authorization, response shaping, or side effects around Harper's native query
|
|
159
|
+
engine:
|
|
160
|
+
|
|
161
|
+
```javascript
|
|
162
|
+
export class Products extends tables.Products {
|
|
163
|
+
static async search(query, context) {
|
|
164
|
+
const safeQuery = {
|
|
165
|
+
...query,
|
|
166
|
+
conditions: [
|
|
167
|
+
...(Array.isArray(query.conditions) ? query.conditions : []),
|
|
168
|
+
{ attribute: 'tenantId', value: context.user.tenantId },
|
|
169
|
+
],
|
|
170
|
+
limit: Math.min(query.limit ?? 50, 100),
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
return super.search(safeQuery, context);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Call table resources directly from other resource methods when you are composing
|
|
179
|
+
server-side behavior:
|
|
180
|
+
|
|
181
|
+
```javascript
|
|
182
|
+
const products = await tables.Products.search({
|
|
183
|
+
conditions: [
|
|
184
|
+
{ attribute: 'category', value: 'software' },
|
|
185
|
+
{ attribute: 'price', comparator: 'less_than', value: 200 },
|
|
186
|
+
],
|
|
187
|
+
sort: { attribute: 'rating', descending: true },
|
|
188
|
+
limit: 20,
|
|
189
|
+
});
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Useful query keys:
|
|
193
|
+
|
|
194
|
+
| Key | Use |
|
|
195
|
+
| --- | --- |
|
|
196
|
+
| `conditions` | Attribute predicates. Use an array for AND-style filters. |
|
|
197
|
+
| `sort` | Sort descriptor. Prefer indexed fields for large result sets. |
|
|
198
|
+
| `limit` | Maximum records returned. Always cap client-controlled values. |
|
|
199
|
+
| `offset` | Pagination offset. Prefer stable sort when offset is used. |
|
|
200
|
+
| `select` | Projection list. Keep admin-only fields out of public responses. |
|
|
201
|
+
| `explain` | Debug execution order and index usage while tuning. |
|
|
202
|
+
|
|
203
|
+
`search()` can return an `AsyncIterable`. When iterating manually or stopping
|
|
204
|
+
early, drain it or call the iterator's `return()` in `finally` so Harper can
|
|
205
|
+
release the read transaction:
|
|
206
|
+
|
|
207
|
+
```javascript
|
|
208
|
+
const iterator = tables.Products
|
|
209
|
+
.search({ conditions: [{ attribute: 'status', value: 'active' }] })
|
|
210
|
+
[Symbol.asyncIterator]();
|
|
211
|
+
|
|
212
|
+
try {
|
|
213
|
+
const first = await iterator.next();
|
|
214
|
+
return first.value;
|
|
215
|
+
} finally {
|
|
216
|
+
await iterator.return?.();
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Context in resource methods
|
|
221
|
+
|
|
222
|
+
Resource methods may receive request context from Harper's REST runtime. Treat
|
|
223
|
+
that context as the authoritative place for user identity, request headers, and
|
|
224
|
+
request-scoped metadata supplied by the server:
|
|
225
|
+
|
|
226
|
+
```javascript
|
|
227
|
+
export class Orders extends tables.Orders {
|
|
228
|
+
static async post(data, context) {
|
|
229
|
+
const userId = context.user?.id;
|
|
230
|
+
if (!userId) {
|
|
231
|
+
throw new Error('Authentication required');
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return super.post(
|
|
235
|
+
{
|
|
236
|
+
...(await data),
|
|
237
|
+
createdBy: userId,
|
|
238
|
+
},
|
|
239
|
+
context,
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
When one resource delegates to another, pass the same `context` through. This
|
|
246
|
+
keeps authorization, headers/request metadata, and transaction ownership aligned
|
|
247
|
+
for nested operations:
|
|
248
|
+
|
|
249
|
+
```javascript
|
|
250
|
+
await tables.OrderEvents.post(
|
|
251
|
+
{
|
|
252
|
+
orderId,
|
|
253
|
+
type: 'created',
|
|
254
|
+
},
|
|
255
|
+
context,
|
|
256
|
+
);
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Do not store `context` in module-level variables. It is request-scoped data and
|
|
260
|
+
must not leak between concurrent requests.
|
|
261
|
+
|
|
262
|
+
## Transactions
|
|
263
|
+
|
|
264
|
+
Harper databases are transactionally consistent. Tables in the same database can
|
|
265
|
+
participate in the same atomic unit of work; separate databases do not preserve
|
|
266
|
+
cross-database atomicity.
|
|
267
|
+
|
|
268
|
+
Resource methods should assume a request-level transaction boundary:
|
|
269
|
+
|
|
270
|
+
- Reads inside a single request observe a consistent transaction context.
|
|
271
|
+
- Writes across tables in the same database commit together when the request
|
|
272
|
+
completes successfully.
|
|
273
|
+
- Throwing from the resource method before completion rolls the request work back.
|
|
274
|
+
- Nested table/resource operations should receive the same `context` to stay in
|
|
275
|
+
the same request transaction.
|
|
276
|
+
- Long-running external calls should happen before writes or after commit-aware
|
|
277
|
+
handoff; do not hold a transaction open while waiting on an avoidable network
|
|
278
|
+
dependency.
|
|
279
|
+
|
|
280
|
+
Example multi-table write:
|
|
281
|
+
|
|
282
|
+
```javascript
|
|
283
|
+
export class Orders extends tables.Orders {
|
|
284
|
+
static async post(data, context) {
|
|
285
|
+
const order = await super.post(await data, context);
|
|
286
|
+
|
|
287
|
+
await tables.OrderEvents.post(
|
|
288
|
+
{
|
|
289
|
+
orderId: order.id,
|
|
290
|
+
type: 'created',
|
|
291
|
+
},
|
|
292
|
+
context,
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
return order;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
If `OrderEvents.post()` throws, the order creation should not be reported as
|
|
301
|
+
successful. Verify the rollback behavior with an integration test against a real
|
|
302
|
+
Harper process when the route writes more than one table.
|
|
303
|
+
|
|
304
|
+
## Verification recipes
|
|
305
|
+
|
|
306
|
+
Filtered, sorted, paginated REST query:
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
curl -fsS "$BASE_URL/products/?category=software&price=gt=100&sort(-rating)&limit(10)" \
|
|
310
|
+
| jq -e '
|
|
311
|
+
length <= 10 and
|
|
312
|
+
all(.[]; .category == "software" and .price > 100)
|
|
313
|
+
'
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Projection:
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
curl -fsS "$BASE_URL/products/?category=software&select(id,name)" \
|
|
320
|
+
| jq -e 'all(.[]; has("id") and has("name") and (has("cost") | not))'
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Relationship traversal:
|
|
324
|
+
|
|
325
|
+
```bash
|
|
326
|
+
curl -fsS "$BASE_URL/products/?brand.name=Microsoft&select(id,name,brand{name})" \
|
|
327
|
+
| jq -e 'all(.[]; .brand.name == "Microsoft")'
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Pagination stability:
|
|
331
|
+
|
|
332
|
+
```bash
|
|
333
|
+
first="$(curl -fsS "$BASE_URL/products/?sort(+createdAt)&limit(0,20)")"
|
|
334
|
+
second="$(curl -fsS "$BASE_URL/products/?sort(+createdAt)&limit(20,40)")"
|
|
335
|
+
jq -e --argjson a "$first" --argjson b "$second" -n '
|
|
336
|
+
(($a | map(.id)) as $left |
|
|
337
|
+
($b | map(.id)) as $right |
|
|
338
|
+
(($left + $right) | unique | length) == (($left | length) + ($right | length)))
|
|
339
|
+
'
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
Multi-table rollback:
|
|
343
|
+
|
|
344
|
+
```bash
|
|
345
|
+
order_id="rollback-$(date +%s)"
|
|
346
|
+
|
|
347
|
+
curl -sS -o /tmp/order-response.json -w "%{http_code}" \
|
|
348
|
+
-X POST "$BASE_URL/orders/" \
|
|
349
|
+
-H 'content-type: application/json' \
|
|
350
|
+
--data "{\"id\":\"$order_id\",\"forceEventFailure\":true}" \
|
|
351
|
+
| grep -E '4[0-9][0-9]|5[0-9][0-9]'
|
|
352
|
+
|
|
353
|
+
curl -fsS "$BASE_URL/orders/$order_id" \
|
|
354
|
+
| jq -e '.error or .message or (.id != "'$order_id'")'
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
For routes with auth rules, add a negative assertion that a user without the
|
|
358
|
+
required role cannot filter, select, or sort on restricted data.
|
|
359
|
+
|
|
360
|
+
## Sources
|
|
361
|
+
|
|
362
|
+
- [REST overview](https://docs.harperdb.io/reference/v5/rest/overview)
|
|
363
|
+
- [REST querying](https://docs.harperdb.io/reference/v5/rest/querying)
|
|
364
|
+
- [Resources overview](https://docs.harperdb.io/reference/v5/resources/overview)
|
|
365
|
+
- [Query optimization](https://docs.harperdb.io/reference/v5/resources/query-optimization)
|
|
366
|
+
- [Database overview](https://docs.harperdb.io/reference/v5/database/overview)
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
display_name: "Harper Rest Queries"
|
|
2
|
+
short_description: "building or debugging Harper (HarperDB/Fabric) REST collection queries and Resource search methods - filters, FIQL comparison operators…"
|
|
3
|
+
default_prompt:
|
|
4
|
+
- "Use $harper-rest-queries: building or debugging Harper (HarperDB/Fabric) REST collection queries and Resource search methods - filters, FIQL comparison operators…."
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: harper-operations
|
|
3
|
+
description: This skill should be used when operating, monitoring, or debugging a Harper (HarperDB/Fabric) component after it builds or deploys - Operations API calls, component inventory, log retrieval, health checks, job lookup, local 500 debugging, and escalation boundaries. Pairs with harper-build-and-deploy, harper-config-yaml, harper-resources, and harper-rest-queries.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Harper Operations
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Use Harper's Operations API when the app built or deployed but runtime behavior is
|
|
11
|
+
unknown: a REST endpoint returns 500, a component did not load, logs show worker
|
|
12
|
+
errors, a table shape differs from the expected schema, or a deploy job needs to be
|
|
13
|
+
checked. The Operations API is the administrative surface; application REST
|
|
14
|
+
endpoints are the user-facing data/resource surface.
|
|
15
|
+
|
|
16
|
+
Cross-check deploy packaging and Fabric topology in [[harper-build-and-deploy]].
|
|
17
|
+
Cross-check active extensions and config replacement behavior in
|
|
18
|
+
[[harper-config-yaml]]. Cross-check custom Resource method ownership in
|
|
19
|
+
[[harper-resources]] and query shape in [[harper-rest-queries]].
|
|
20
|
+
|
|
21
|
+
## Endpoint, auth, and request shape
|
|
22
|
+
|
|
23
|
+
Operations API requests are JSON `POST` requests to the operations endpoint. Harper
|
|
24
|
+
listens on port `9925` at the root path by default:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
curl -sS http://<harper-host>:9925/ \
|
|
28
|
+
-u "$HARPER_USERNAME:$HARPER_PASSWORD" \
|
|
29
|
+
-H 'Content-Type: application/json' \
|
|
30
|
+
--data '{"operation":"system_information"}'
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
For local development:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
curl -sS http://localhost:9925/ \
|
|
37
|
+
-u "$HARPER_USERNAME:$HARPER_PASSWORD" \
|
|
38
|
+
-H 'Content-Type: application/json' \
|
|
39
|
+
--data '{"operation":"get_components"}'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Authentication options:
|
|
43
|
+
|
|
44
|
+
- Basic auth: `Authorization: Basic ...`, or `curl -u "$USER:$PASS"`.
|
|
45
|
+
- JWT operation token: `Authorization: Bearer <token>` from
|
|
46
|
+
`create_authentication_tokens`.
|
|
47
|
+
- CLI: `harper login <target>` for persistent remote auth, or environment
|
|
48
|
+
credentials such as `HARPER_CLI_USERNAME` / `HARPER_CLI_PASSWORD`.
|
|
49
|
+
|
|
50
|
+
Most operational reads require a `super_user` or a role explicitly allowed to run
|
|
51
|
+
the named operation. If an operation is denied, check role `operations` permissions
|
|
52
|
+
before assuming the endpoint or component is broken.
|
|
53
|
+
|
|
54
|
+
## High-value operations
|
|
55
|
+
|
|
56
|
+
| Operation | Use it for | Example |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| `get_components` | Confirm component names, files, and configuration loaded from `harper-config.yaml`. | `{"operation":"get_components"}` |
|
|
59
|
+
| `describe_all` | See all database/table definitions and record counts visible to the caller. | `{"operation":"describe_all"}` |
|
|
60
|
+
| `describe_table` | Confirm table/database names, attributes, and primary key shape. | `{"operation":"describe_table","database":"data","table":"Product"}` |
|
|
61
|
+
| `system_information` | Capture runtime, host, and process information for health/debug reports. | `{"operation":"system_information"}` |
|
|
62
|
+
| `read_log` | Read Harper's primary `hdb.log` with level/time/filter controls. | `{"operation":"read_log","level":"error","limit":50,"order":"desc"}` |
|
|
63
|
+
| `search_jobs_by_start_date` | Find background jobs when deploys, imports, or long operations are involved. | `{"operation":"search_jobs_by_start_date","from_date":"2026-06-16T00:00:00.000+0000","to_date":"2026-06-17T00:00:00.000+0000"}` |
|
|
64
|
+
| `get_job` | Inspect one known job id returned by a search or operation response. | `{"operation":"get_job","id":"<job-id>"}` |
|
|
65
|
+
| `get_configuration` | Find runtime paths such as `rootPath`, `componentsRoot`, ports, and logging config. | `{"operation":"get_configuration"}` |
|
|
66
|
+
|
|
67
|
+
Use CLI shortcuts when the operation only needs flat key/value arguments:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
harper get_components target="$HARPER_TARGET" json=true
|
|
71
|
+
harper describe_all target="$HARPER_TARGET" json=true
|
|
72
|
+
harper read_log target="$HARPER_TARGET" level=error limit=50 order=desc json=true
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
If the CLI cannot represent the nested request body, use `curl` against the
|
|
76
|
+
Operations API directly.
|
|
77
|
+
|
|
78
|
+
## Reading logs
|
|
79
|
+
|
|
80
|
+
`read_log` reads the primary Harper log (`hdb.log`) and is restricted to
|
|
81
|
+
`super_user` roles unless a custom role grants it. Useful parameters include
|
|
82
|
+
`level`, `from`, `until`, `limit`, `order`, and `filter`.
|
|
83
|
+
|
|
84
|
+
Recent errors:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
curl -sS "$HARPER_TARGET" \
|
|
88
|
+
-u "$HARPER_USERNAME:$HARPER_PASSWORD" \
|
|
89
|
+
-H 'Content-Type: application/json' \
|
|
90
|
+
--data '{
|
|
91
|
+
"operation": "read_log",
|
|
92
|
+
"level": "error",
|
|
93
|
+
"limit": 50,
|
|
94
|
+
"order": "desc"
|
|
95
|
+
}'
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Filter by component, route, or correlation id:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
curl -sS "$HARPER_TARGET" \
|
|
102
|
+
-u "$HARPER_USERNAME:$HARPER_PASSWORD" \
|
|
103
|
+
-H 'Content-Type: application/json' \
|
|
104
|
+
--data '{
|
|
105
|
+
"operation": "read_log",
|
|
106
|
+
"filter": "orders",
|
|
107
|
+
"from": "2026-06-16 00:00:00",
|
|
108
|
+
"limit": 100,
|
|
109
|
+
"order": "desc"
|
|
110
|
+
}'
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
In local `harper dev`, also watch the terminal output. The dev command restarts
|
|
114
|
+
worker threads on file changes and prints console/log output close to the failing
|
|
115
|
+
request. Use `harper run` or a deployed local instance when you need to restart the
|
|
116
|
+
main thread, not only workers.
|
|
117
|
+
|
|
118
|
+
## Logging from Resources
|
|
119
|
+
|
|
120
|
+
For Resource methods, log enough to identify the request path, authenticated user
|
|
121
|
+
or tenant id, and failing branch without emitting secrets or whole request bodies.
|
|
122
|
+
Prefer structured, searchable messages:
|
|
123
|
+
|
|
124
|
+
```javascript
|
|
125
|
+
export class Orders extends tables.Orders {
|
|
126
|
+
static async post(data, context) {
|
|
127
|
+
const input = await data;
|
|
128
|
+
console.info('orders.post received', {
|
|
129
|
+
orderId: input.id,
|
|
130
|
+
userId: context.user?.id,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
try {
|
|
134
|
+
return await super.post(input, context);
|
|
135
|
+
} catch (error) {
|
|
136
|
+
console.error('orders.post failed', {
|
|
137
|
+
orderId: input.id,
|
|
138
|
+
message: error?.message,
|
|
139
|
+
});
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Guidance:
|
|
147
|
+
|
|
148
|
+
- Use `console.info` or `console.debug` for normal trace points, and
|
|
149
|
+
`console.warn` / `console.error` for actionable failures.
|
|
150
|
+
- Never log passwords, tokens, cookies, API keys, raw Authorization headers, or
|
|
151
|
+
full personal data payloads.
|
|
152
|
+
- Include a request id or deterministic entity id when the caller can provide one.
|
|
153
|
+
- Remove noisy temporary logs once the root cause is fixed, or lower them to debug.
|
|
154
|
+
|
|
155
|
+
## Debugging a 500 endpoint
|
|
156
|
+
|
|
157
|
+
When a deployed REST endpoint returns 500, follow this path before changing code:
|
|
158
|
+
|
|
159
|
+
1. Identify the exact endpoint, method, payload, authenticated user, target URL,
|
|
160
|
+
and timestamp. Save a reproducible `curl` command with headers scrubbed.
|
|
161
|
+
2. Confirm the component is installed and named as expected:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
harper get_components target="$HARPER_TARGET" json=true
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
3. Read recent errors around the failing timestamp:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
harper read_log target="$HARPER_TARGET" level=error limit=100 order=desc json=true
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
4. Check table/resource shape when the failure mentions a missing table, attribute,
|
|
174
|
+
index, relationship, or schema directive:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
curl -sS "$HARPER_TARGET" \
|
|
178
|
+
-u "$HARPER_USERNAME:$HARPER_PASSWORD" \
|
|
179
|
+
-H 'Content-Type: application/json' \
|
|
180
|
+
--data '{"operation":"describe_all"}'
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
5. Reproduce locally with the same built artifact path:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
bun run build
|
|
187
|
+
harper dev harper-app
|
|
188
|
+
curl -i http://localhost:9926/<project>/<resource-path>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
6. Isolate the smallest Resource method or table call involved. If the route uses a
|
|
192
|
+
custom Resource, call its underlying table/search operation directly when safe,
|
|
193
|
+
then add one temporary log at the branch boundary that chooses the failing path.
|
|
194
|
+
7. Fix source files, not generated deploy artifacts. Rebuild and repeat the same
|
|
195
|
+
local `curl`, then repeat the deployed smoke path after redeploy.
|
|
196
|
+
|
|
197
|
+
Treat the incident as unresolved until the same request path returns the expected
|
|
198
|
+
status and the logs no longer show the error.
|
|
199
|
+
|
|
200
|
+
## Health and deploy checks
|
|
201
|
+
|
|
202
|
+
After deploy or restart, check:
|
|
203
|
+
|
|
204
|
+
- Component inventory: `get_components` includes the expected project and files.
|
|
205
|
+
- System/runtime info: `system_information` returns from the target node.
|
|
206
|
+
- Configuration: `get_configuration` shows the expected operations/API ports,
|
|
207
|
+
`rootPath`, `componentsRoot`, and logging configuration.
|
|
208
|
+
- Schema/data shape: `describe_all` or `describe_table` matches the expected
|
|
209
|
+
database/table definitions and exported tables.
|
|
210
|
+
- Logs: `read_log` has no new error entries for the deploy/restart window.
|
|
211
|
+
- Jobs: `search_jobs_by_start_date` and `get_job` show background work completed
|
|
212
|
+
when deploy, import, backup, or long-running data operations were involved.
|
|
213
|
+
- Public smoke: the project-specific HTTP smoke command passes from the same route
|
|
214
|
+
users will hit. For Fabric, verify through the public route and any direct
|
|
215
|
+
node/region route the project exposes.
|
|
216
|
+
|
|
217
|
+
## What is not available
|
|
218
|
+
|
|
219
|
+
Do not invent observability that the target does not expose:
|
|
220
|
+
|
|
221
|
+
- If there is no Fabric credential or operations role, you cannot prove remote
|
|
222
|
+
component state; ask for credentials or a trusted operator readback.
|
|
223
|
+
- If the app does not emit a request id, logs may not be attributable to one HTTP
|
|
224
|
+
request. Reproduce in a narrow time window or add a safe correlation id first.
|
|
225
|
+
- If a Fabric project hides direct node/region URLs, verify through the public
|
|
226
|
+
route and record that node-level proof is unavailable.
|
|
227
|
+
- If Harper returns an auth/permission denial for `read_log`,
|
|
228
|
+
`system_information`, or component operations, treat it as an access blocker,
|
|
229
|
+
not as evidence that logs or components are empty.
|
|
230
|
+
- Third-party APM, trace collection, and performance tuning are outside this
|
|
231
|
+
skill. Capture Harper-native facts first, then escalate to the project's
|
|
232
|
+
runbook or platform owner.
|
|
233
|
+
|
|
234
|
+
## Sources
|
|
235
|
+
|
|
236
|
+
- [Operations API Overview](https://docs.harperdb.io/reference/v5/operations-api/overview)
|
|
237
|
+
- [Operations Reference](https://docs.harperdb.io/reference/v5/operations-api/operations)
|
|
238
|
+
- [Logging Operations](https://docs.harperdb.io/reference/v5/logging/operations)
|
|
239
|
+
- [Applications / Component Operations](https://docs.harperdb.io/reference/v5/components/applications)
|