@yottagraph-app/aether-instructions 1.1.20 → 1.1.21
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/rules/api.mdc +7 -33
- package/rules/cookbook.mdc +12 -2
package/package.json
CHANGED
package/rules/api.mdc
CHANGED
|
@@ -85,19 +85,12 @@ import { useElementalClient } from '@yottagraph-app/elemental-api/client';
|
|
|
85
85
|
const client = useElementalClient();
|
|
86
86
|
|
|
87
87
|
const schema = await client.getSchema();
|
|
88
|
-
const report = await client.getNamedEntityReport('00508379502570440213');
|
|
89
88
|
const entities = await client.findEntities({
|
|
90
89
|
expression: JSON.stringify({ type: 'comparison', comparison: { operator: 'string_like', pid: 8, value: 'Apple' } }),
|
|
91
90
|
limit: 5,
|
|
92
91
|
});
|
|
93
92
|
```
|
|
94
93
|
|
|
95
|
-
Types are also imported from the client:
|
|
96
|
-
|
|
97
|
-
```typescript
|
|
98
|
-
import type { NamedEntityReport } from '@yottagraph-app/elemental-api/client';
|
|
99
|
-
```
|
|
100
|
-
|
|
101
94
|
### Client Method Quick Reference
|
|
102
95
|
|
|
103
96
|
All methods return data directly and throw on non-2xx responses.
|
|
@@ -107,14 +100,17 @@ All methods return data directly and throw on non-2xx responses.
|
|
|
107
100
|
| Method | Signature | Purpose |
|
|
108
101
|
|---|---|---|
|
|
109
102
|
| `findEntities` | `(body: FindEntitiesBody)` | Expression-based search (see `find.md`) |
|
|
110
|
-
| `getNamedEntityReport` | `(neid: string)` | Entity details (name, aliases, type) |
|
|
111
|
-
| `getEntityDetails` | `(neid: string)` | Alias for entity reports |
|
|
112
103
|
|
|
113
104
|
> **Entity search**: Use `findEntities()` with `string_like` on the name PID
|
|
114
105
|
> for name-based searches, or call `POST /entities/search` directly via
|
|
115
106
|
> `$fetch` for batch name resolution with scored ranking (this endpoint is
|
|
116
107
|
> not wrapped by the generated client).
|
|
117
108
|
|
|
109
|
+
> **Entity name lookup**: To get an entity's display name from its NEID,
|
|
110
|
+
> call `GET /entities/{neid}/name` directly via `$fetch` (not on the
|
|
111
|
+
> generated client). Returns `{"name": "..."}`. For all other entity
|
|
112
|
+
> data, use `getPropertyValues()`.
|
|
113
|
+
|
|
118
114
|
**Properties and schema:**
|
|
119
115
|
|
|
120
116
|
| Method | Signature | Purpose |
|
|
@@ -188,35 +184,13 @@ const flavors = res.schema?.flavors ?? (res as any).flavors ?? [];
|
|
|
188
184
|
The `(res as any).properties` fallback is there in case the API is ever
|
|
189
185
|
fixed to match the types. Use this pattern every time.
|
|
190
186
|
|
|
191
|
-
### `getNamedEntityReport()` response is nested under `.report`
|
|
192
|
-
|
|
193
|
-
Same problem as `getSchema()`. The TypeScript types suggest entity fields
|
|
194
|
-
(`name`, `aliases`, `type`) exist at the top level. **They don't.** The
|
|
195
|
-
API wraps them in a `.report` container. The generated client does NOT
|
|
196
|
-
unwrap this automatically.
|
|
197
|
-
|
|
198
|
-
```typescript
|
|
199
|
-
// WRONG — name will be undefined:
|
|
200
|
-
const res = await client.getNamedEntityReport(neid);
|
|
201
|
-
const name = res.name; // undefined!
|
|
202
|
-
|
|
203
|
-
// CORRECT — always access through .report:
|
|
204
|
-
const res = await client.getNamedEntityReport(neid);
|
|
205
|
-
const name = res.report?.name ?? (res as any).name ?? neid;
|
|
206
|
-
const aliases = res.report?.aliases ?? (res as any).aliases ?? [];
|
|
207
|
-
const type = res.report?.type ?? (res as any).type;
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
The `(res as any).name` fallback handles the case where the client is
|
|
211
|
-
eventually fixed to unwrap the response.
|
|
212
|
-
|
|
213
187
|
### Relationship property values need zero-padding to form valid NEIDs
|
|
214
188
|
|
|
215
189
|
Relationship properties (`data_nindex`) return linked entity IDs as raw
|
|
216
190
|
numbers (e.g. `4926132345040704022`). These must be **zero-padded to 20
|
|
217
191
|
characters** to form valid NEIDs. This is easy to miss and causes silent
|
|
218
|
-
failures — `
|
|
219
|
-
returns
|
|
192
|
+
failures — `getPropertyValues` returns empty results and
|
|
193
|
+
`/entities/{neid}/name` returns a 404.
|
|
220
194
|
|
|
221
195
|
```typescript
|
|
222
196
|
// WRONG — raw value is NOT a valid NEID:
|
package/rules/cookbook.mdc
CHANGED
|
@@ -501,11 +501,21 @@ relationship PID. See the `api` rule for the two-layer architecture.
|
|
|
501
501
|
String(v.value).padStart(20, '0'),
|
|
502
502
|
);
|
|
503
503
|
|
|
504
|
+
function getEntityNameUrl(neid: string) {
|
|
505
|
+
const config = useRuntimeConfig();
|
|
506
|
+
const gw = (config.public as any).gatewayUrl as string;
|
|
507
|
+
const org = (config.public as any).tenantOrgId as string;
|
|
508
|
+
return `${gw}/api/qs/${org}/entities/${neid}/name`;
|
|
509
|
+
}
|
|
510
|
+
|
|
504
511
|
const names = await Promise.all(
|
|
505
512
|
docNeids.map(async (neid: string) => {
|
|
506
513
|
try {
|
|
507
|
-
const
|
|
508
|
-
|
|
514
|
+
const res = await $fetch<{ name: string }>(
|
|
515
|
+
getEntityNameUrl(neid),
|
|
516
|
+
{ headers: { 'X-Api-Key': getApiKey() } },
|
|
517
|
+
);
|
|
518
|
+
return res.name || neid;
|
|
509
519
|
} catch {
|
|
510
520
|
return neid;
|
|
511
521
|
}
|