@qaecy/cue-sdk 0.0.50 → 0.0.53
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/browser.js +17623 -26418
- package/{document-filter-C9Og2u8R.js → document-filter-CBrY09DH.js} +2574 -1681
- package/index.d.ts +9 -3
- package/index.js +59 -39
- package/lib/api.d.ts +42 -8
- package/lib/auth.d.ts +9 -0
- package/lib/cue.d.ts +1 -1
- package/lib/data-sources.d.ts +223 -2
- package/lib/documents.d.ts +1 -1
- package/lib/entities.d.ts +137 -5
- package/lib/extraction.d.ts +4 -3
- package/lib/gis.d.ts +1 -1
- package/lib/index-api.d.ts +61 -4
- package/lib/llm-tools.d.ts +262 -0
- package/lib/models.d.ts +167 -16
- package/lib/privileges.d.ts +1 -0
- package/lib/profile.d.ts +1 -11
- package/lib/project-schema.d.ts +25 -0
- package/lib/project.d.ts +22 -8
- package/lib/schema-suggestion.d.ts +81 -0
- package/lib/semantic-template.d.ts +61 -0
- package/lib/sync.d.ts +14 -4
- package/node.js +61 -41
- package/package.json +1 -1
- package/variables.d.ts +7 -4
package/lib/entities.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CueApi } from './api';
|
|
2
2
|
import { ReadonlySignal } from './signal';
|
|
3
|
-
import { EntityDetailedData, EntityRelationships, ProjectEntitiesData, SummaryGraphData } from './models';
|
|
3
|
+
import { EntityAtExpressId, EntityDetailedData, EntityModelLocation, EntityRelationships, ModelExpressIds, ProjectEntitiesData, PrototypeCategoryCount, PrototypeCategoryExpressIds, PrototypeInstance, PrototypeProperty, PrototypeSummary, SummaryGraphData } from './models';
|
|
4
4
|
/**
|
|
5
5
|
* Manages entity data for a single project.
|
|
6
6
|
*
|
|
@@ -148,6 +148,118 @@ export declare class CueProjectEntities {
|
|
|
148
148
|
value: string;
|
|
149
149
|
categories: string[];
|
|
150
150
|
}>>;
|
|
151
|
+
/**
|
|
152
|
+
* Fetches every entity category that has at least one `qcy:EntityPrototype`,
|
|
153
|
+
* with the number of prototypes in it, most populous first.
|
|
154
|
+
*
|
|
155
|
+
* Labels use `api.language` (default `'en'`), falling back to an untagged
|
|
156
|
+
* `skos:prefLabel` and then to the IRI fragment.
|
|
157
|
+
*/
|
|
158
|
+
prototypeCategories(): Promise<PrototypeCategoryCount[]>;
|
|
159
|
+
/**
|
|
160
|
+
* Fetches the prototypes belonging to one category, most-inherited first.
|
|
161
|
+
*
|
|
162
|
+
* Accepts both a full HTTP IRI and a prefixed form (`qcy-e:Door`).
|
|
163
|
+
*/
|
|
164
|
+
prototypesByCategory(categoryIri: string): Promise<PrototypeSummary[]>;
|
|
165
|
+
/**
|
|
166
|
+
* Fetches the `qcy:Property` nodes hanging off one entity, grouped in the
|
|
167
|
+
* result order by IFC property set.
|
|
168
|
+
*
|
|
169
|
+
* Works for any entity, not just a prototype — an occurrence carries the
|
|
170
|
+
* properties that differ from what it inherits.
|
|
171
|
+
*/
|
|
172
|
+
prototypeProperties(entityIri: string): Promise<PrototypeProperty[]>;
|
|
173
|
+
/**
|
|
174
|
+
* Fetches a page of the entities that inherit from one prototype.
|
|
175
|
+
*
|
|
176
|
+
* Paginated because a single type object can have thousands of occurrences.
|
|
177
|
+
* The total is already known from `prototypesByCategory`'s `instanceCount`,
|
|
178
|
+
* so there's no separate count query here.
|
|
179
|
+
*/
|
|
180
|
+
prototypeInstances(prototypeIri: string, opts?: {
|
|
181
|
+
limit?: number;
|
|
182
|
+
offset?: number;
|
|
183
|
+
}): Promise<PrototypeInstance[]>;
|
|
184
|
+
/**
|
|
185
|
+
* Resolves entity IRIs to their express IDs inside the models they came from.
|
|
186
|
+
*
|
|
187
|
+
* Accepts both `qcy:EntityMention` IRIs (what the prototype browser lists) and
|
|
188
|
+
* `qcy:CanonicalEntity` IRIs — for the latter the query hops the mentions that
|
|
189
|
+
* `qcy:resolvesTo` them, since selectors only ever hang off mentions. Pass
|
|
190
|
+
* `viaMentions: false` to skip that hop when the caller knows it holds mentions.
|
|
191
|
+
*
|
|
192
|
+
* One entity can resolve to several rows: a federated project mentions the same
|
|
193
|
+
* entity from more than one model, and each model has its own express ID.
|
|
194
|
+
*
|
|
195
|
+
* Resolve `modelUuid` to a loadable file with `CueProjectDocuments`
|
|
196
|
+
* (`fetchDocumentDataSimple`) and the storage download URL.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* const hits = await entities.entityExpressIds([instance.iri]);
|
|
201
|
+
* // → [{ requestedIri, mentionIri, modelIri, modelUuid, expressId: 1234 }]
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
entityExpressIds(entityIris: string[], opts?: {
|
|
205
|
+
viaMentions?: boolean;
|
|
206
|
+
}): Promise<EntityModelLocation[]>;
|
|
207
|
+
/**
|
|
208
|
+
* Resolves every occurrence of one prototype to its express ID, grouped by the
|
|
209
|
+
* model it lives in — the shape a viewer needs to load a model and highlight
|
|
210
|
+
* all of that type's instances at once. Models with the most occurrences come
|
|
211
|
+
* first.
|
|
212
|
+
*
|
|
213
|
+
* A prototype is an IFC type object and carries no selector itself, so this
|
|
214
|
+
* traverses `qcy:inheritsFrom` to the occurrences and reads theirs. Passing a
|
|
215
|
+
* prototype IRI to `entityExpressIds` returns nothing for that reason.
|
|
216
|
+
*
|
|
217
|
+
* Unpaginated: a type object with thousands of occurrences yields thousands of
|
|
218
|
+
* integers, which is still a small payload and has to be complete for the
|
|
219
|
+
* viewer to highlight them all.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```ts
|
|
223
|
+
* const groups = await entities.prototypeExpressIds(prototype.iri);
|
|
224
|
+
* // → [{ modelIri, modelUuid, expressIds: [12, 48, 91, …] }]
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
prototypeExpressIds(prototypeIri: string): Promise<ModelExpressIds[]>;
|
|
228
|
+
/**
|
|
229
|
+
* The entity one express ID stands for inside one model, plus the prototype
|
|
230
|
+
* and category to browse it by — the reverse of `entityExpressIds`, for
|
|
231
|
+
* turning a click in a model viewer back into a graph selection.
|
|
232
|
+
*
|
|
233
|
+
* `modelIri` is the `qcy:FileContent` IRI, the same `modelIri` the other
|
|
234
|
+
* selector methods return; a viewer usually holds only the UUID, so keep the
|
|
235
|
+
* mapping the occurrence query already handed you.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```ts
|
|
239
|
+
* const hit = await entities.entityAtExpressId(modelIri, 1234);
|
|
240
|
+
* // → { entityIri, value, prototypeIri, categoryIri }
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
entityAtExpressId(modelIri: string, expressId: number): Promise<EntityAtExpressId | undefined>;
|
|
244
|
+
/**
|
|
245
|
+
* Every occurrence of every prototype in one entity category, grouped by
|
|
246
|
+
* prototype and model — what a viewer needs to colour a whole category, one
|
|
247
|
+
* colour per prototype, without a query per prototype.
|
|
248
|
+
*
|
|
249
|
+
* Same traversal as `prototypeExpressIds`, with the prototype left unbound and
|
|
250
|
+
* constrained by `qcy:hasEntityCategory` the way `prototypesByCategory` does,
|
|
251
|
+
* so a compact category IRI is expanded first.
|
|
252
|
+
*
|
|
253
|
+
* Unpaginated, and a category is a good deal larger than a single prototype:
|
|
254
|
+
* expect tens of thousands of integers for a real project.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* const groups = await entities.categoryExpressIds('beo:Wall');
|
|
259
|
+
* // → [{ prototypeIri, modelIri, modelUuid, expressIds: [12, 48, …] }]
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
categoryExpressIds(categoryIri: string): Promise<PrototypeCategoryExpressIds[]>;
|
|
151
263
|
/**
|
|
152
264
|
* Fetches a summary graph of entity category relationships for the project.
|
|
153
265
|
*
|
|
@@ -165,6 +277,13 @@ export declare class CueProjectEntities {
|
|
|
165
277
|
* the source or target category equals this IRI are returned — i.e. the
|
|
166
278
|
* one-hop neighbourhood of that category.
|
|
167
279
|
*
|
|
280
|
+
* @param namedGraph Optional named-graph IRI to scope the summary to (e.g.
|
|
281
|
+
* one data source's own graph) instead of the whole project. Bypasses the
|
|
282
|
+
* QLever materialized view (which is project-wide and can't be scoped) and
|
|
283
|
+
* skips the project-wide category-count enrichment on `format: 'graph'`
|
|
284
|
+
* entities — a project-wide weight next to a single scoped graph's
|
|
285
|
+
* relations would be misleading.
|
|
286
|
+
*
|
|
168
287
|
* @example
|
|
169
288
|
* ```ts
|
|
170
289
|
* // Structured graph (nodes + edges)
|
|
@@ -175,14 +294,27 @@ export declare class CueProjectEntities {
|
|
|
175
294
|
* // Neighbourhood of a single category (prefixed IRI)
|
|
176
295
|
* const g2 = await entities.buildSummaryGraph('graph', 'qcy:Building');
|
|
177
296
|
*
|
|
297
|
+
* // Scoped to one data source's own named graph
|
|
298
|
+
* const g3 = await entities.buildSummaryGraph('graph', undefined, 'https://cue.qaecy.com/r/p1/datasource/d1');
|
|
299
|
+
*
|
|
178
300
|
* // Markdown table
|
|
179
301
|
* const md = await entities.buildSummaryGraph('md');
|
|
180
|
-
* // qcy:FloorPlanDrawing ->
|
|
302
|
+
* // qcy:FloorPlanDrawing -> includesBuildingEntity -> qcy:BuildingZone (5652)
|
|
181
303
|
* ```
|
|
182
304
|
*/
|
|
183
|
-
buildSummaryGraph(format: 'graph', entityIRI?: string): Promise<SummaryGraphData>;
|
|
184
|
-
buildSummaryGraph(format: 'md', entityIRI?: string): Promise<string>;
|
|
185
|
-
buildSummaryGraph(format?: undefined, entityIRI?: string): Promise<unknown>;
|
|
305
|
+
buildSummaryGraph(format: 'graph', entityIRI?: string, namedGraph?: string): Promise<SummaryGraphData>;
|
|
306
|
+
buildSummaryGraph(format: 'md', entityIRI?: string, namedGraph?: string): Promise<string>;
|
|
307
|
+
buildSummaryGraph(format?: undefined, entityIRI?: string, namedGraph?: string): Promise<unknown>;
|
|
308
|
+
/**
|
|
309
|
+
* Turns one selector binding into a location, dropping rows whose express ID
|
|
310
|
+
* is not a number.
|
|
311
|
+
*/
|
|
312
|
+
private _toModelLocation;
|
|
313
|
+
/**
|
|
314
|
+
* Express IDs are written as plain string literals, so a non-numeric value is
|
|
315
|
+
* possible in principle — dropping such a row beats handing a viewer `NaN`.
|
|
316
|
+
*/
|
|
317
|
+
private _parseExpressId;
|
|
186
318
|
/**
|
|
187
319
|
* Fetches the category-summary rows. On QLever the pre-computed
|
|
188
320
|
* `entity-summary` materialized view is tried first; if it yields no rows we
|
package/lib/extraction.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { ProjectSchema } from '../../models/src/index';
|
|
1
2
|
import { CueAuth } from './auth';
|
|
2
3
|
export declare const ENDPOINT_EXTRACTION = "/semantic-extraction/extract";
|
|
3
4
|
export interface ExtractionRequest {
|
|
4
5
|
/** PNG (or other image) blob of the document page to extract from. */
|
|
5
6
|
image: Blob;
|
|
6
|
-
/**
|
|
7
|
-
|
|
7
|
+
/** The `ProjectSchema` to extract with, as a JSON object. */
|
|
8
|
+
projectSchema: ProjectSchema;
|
|
8
9
|
/** Project / space ID used by the extraction service. */
|
|
9
10
|
projectId: string;
|
|
10
11
|
/** IRI of the pre-selected content category; omit to let the model classify. */
|
|
@@ -27,7 +28,7 @@ export interface ExtractionResponse {
|
|
|
27
28
|
* ```ts
|
|
28
29
|
* const result = await cue.api.extraction.extract({
|
|
29
30
|
* image: pngBlob,
|
|
30
|
-
*
|
|
31
|
+
* projectSchema: mySchema,
|
|
31
32
|
* projectId: 'my-project',
|
|
32
33
|
* });
|
|
33
34
|
* // result.jsonld is a JSON-LD document for cue-rdf-graph
|
package/lib/gis.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BBox, FeatureCategory, FeatureCategoryDescriptor, GisFeature } from '
|
|
1
|
+
import { BBox, FeatureCategory, FeatureCategoryDescriptor, GisFeature } from '../../../cue-gis/src/index.ts';
|
|
2
2
|
export type GisBBox = BBox;
|
|
3
3
|
export type { FeatureCategory };
|
|
4
4
|
export type GisCategoryDescriptor = FeatureCategoryDescriptor;
|
package/lib/index-api.d.ts
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { CueAuth } from './auth';
|
|
2
|
-
import { AvailableFiltersResponse, IndexAppliedFilters, IndexSearchRequest, IndexSearchResponse } from './models';
|
|
2
|
+
import { AvailableFiltersResponse, IndexAppliedFilters, IndexSearchRequest, IndexSearchResponse, QleverStats } from './models';
|
|
3
|
+
interface RebuildProgress {
|
|
4
|
+
status: 'in-progress' | 'finished' | 'error';
|
|
5
|
+
message: string;
|
|
6
|
+
success?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface MigrateAllResult {
|
|
9
|
+
projectId: string;
|
|
10
|
+
outcome: 'migrated' | 'skipped' | 'failed';
|
|
11
|
+
message: string;
|
|
12
|
+
}
|
|
13
|
+
export interface MigrateAllProgress extends RebuildProgress {
|
|
14
|
+
summary?: {
|
|
15
|
+
migrated: number;
|
|
16
|
+
skipped: number;
|
|
17
|
+
failed: number;
|
|
18
|
+
};
|
|
19
|
+
results?: MigrateAllResult[];
|
|
20
|
+
}
|
|
3
21
|
export declare class CueIndexApi {
|
|
4
22
|
private readonly _auth;
|
|
5
23
|
private readonly _gatewayUrl;
|
|
@@ -29,13 +47,52 @@ export declare class CueIndexApi {
|
|
|
29
47
|
*/
|
|
30
48
|
rebuild(projectId: string, onProgress?: (message: string) => void): Promise<string>;
|
|
31
49
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* Super-admin only.
|
|
50
|
+
* Upgrades the project's QLever index to the currently-deployed CLI's index
|
|
51
|
+
* format (see `QleverStats.qleverVersion` vs. `currentQleverVersion`).
|
|
52
|
+
* Super-admin only. Streams NDJSON progress lines from the backend, same
|
|
53
|
+
* contract as `rebuild()` above; a no-op if the index already matches.
|
|
54
|
+
*/
|
|
55
|
+
migrate(projectId: string, onProgress?: (message: string) => void): Promise<string>;
|
|
56
|
+
/**
|
|
57
|
+
* Upgrades every project's QLever index to the currently-deployed CLI's
|
|
58
|
+
* index format in one call — same backend as `migrate()`, but omits
|
|
59
|
+
* `projectId` from the request body so the graph engine loops over every
|
|
60
|
+
* project on the volume itself. Super-admin only.
|
|
61
|
+
*
|
|
62
|
+
* `anyProjectId` is only there to satisfy the gateway's `x-project-id`
|
|
63
|
+
* header requirement (any project the caller can see works — the backend
|
|
64
|
+
* ignores it for scoping and migrates everything regardless). Streams
|
|
65
|
+
* NDJSON progress lines like `migrate()`; the final line additionally
|
|
66
|
+
* carries `summary` (migrated/skipped/failed counts) and `results` (one
|
|
67
|
+
* entry per project). Only throws on a hard failure of the operation
|
|
68
|
+
* itself — a project failing to migrate is reported in `results`, not
|
|
69
|
+
* thrown.
|
|
70
|
+
*/
|
|
71
|
+
migrateAll(anyProjectId: string, onProgress?: (message: string) => void, force?: boolean): Promise<MigrateAllProgress>;
|
|
72
|
+
/**
|
|
73
|
+
* This project's combined graph+fts+vector+ledger stats, straight off
|
|
74
|
+
* `databases-cue` — every project member can call this (unlike `refreshStats`
|
|
75
|
+
* below), since it only reads.
|
|
76
|
+
*/
|
|
77
|
+
stats(projectId: string): Promise<QleverStats>;
|
|
78
|
+
/**
|
|
79
|
+
* Recomputes the graph engine's stats aggregate (document count, index size,
|
|
80
|
+
* materialized views — FTS and vector always answer live, so there is
|
|
81
|
+
* nothing to recompute for them) and persists the result, bypassing the
|
|
82
|
+
* normal cache TTL. Super-admin only. Resolves with a summary message.
|
|
35
83
|
*
|
|
36
84
|
* Pass `projectId` to refresh that project alone — the usual case, and much
|
|
37
85
|
* cheaper. Omit it to re-scan EVERY project on the volume, which costs several
|
|
38
86
|
* SPARQL queries per index and can run for minutes.
|
|
39
87
|
*/
|
|
40
88
|
refreshStats(projectId?: string): Promise<string>;
|
|
89
|
+
/**
|
|
90
|
+
* Restores every idled engine's data from cloud storage — `databases-cue`'s
|
|
91
|
+
* `/warm-up`, the same restore a query triggers automatically on a miss, run
|
|
92
|
+
* explicitly so a user can bring a project back without just querying it and
|
|
93
|
+
* hoping. Every project member can call this: it only restores data the
|
|
94
|
+
* project already owns. Resolves with a status message.
|
|
95
|
+
*/
|
|
96
|
+
warmUp(projectId: string): Promise<string>;
|
|
41
97
|
}
|
|
98
|
+
export {};
|
package/lib/llm-tools.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { CueAuth } from './auth';
|
|
2
|
+
import { ProjectSchema } from '../../models/src/index';
|
|
2
3
|
export declare const ENDPOINT_WRANGLING_SCHEMA_GENERATE = "/llm-tools/wrangling-schema/generate";
|
|
3
4
|
export declare const ENDPOINT_WRANGLING_SCHEMA_REFINE = "/llm-tools/wrangling-schema/refine";
|
|
4
5
|
export declare const ENDPOINT_ENTITY_CATEGORY_SUGGEST = "/llm-tools/entity-category-suggestion/suggest";
|
|
5
6
|
export declare const ENDPOINT_ENTITY_CATEGORY_SUGGEST_BATCH = "/llm-tools/entity-category-suggestion/suggest-batch";
|
|
7
|
+
export declare const ENDPOINT_SCHEMA_SUGGESTION_FROM_PROSE = "/llm-tools/schema-suggestion/from-prose";
|
|
8
|
+
export declare const ENDPOINT_SCHEMA_SUGGESTION_FROM_IMAGES = "/llm-tools/schema-suggestion/from-images";
|
|
9
|
+
export declare const ENDPOINT_SCHEMA_SUGGESTION_PARSE_CODING_SCHEME = "/llm-tools/schema-suggestion/parse-coding-scheme";
|
|
10
|
+
export declare const ENDPOINT_SCHEMA_SUGGESTION_FROM_CODING_SCHEME = "/llm-tools/schema-suggestion/from-coding-scheme";
|
|
11
|
+
export declare const ENDPOINT_SCHEMA_SUGGESTION_FROM_COLUMNS = "/llm-tools/schema-suggestion/from-columns";
|
|
12
|
+
export declare const ENDPOINT_SCHEMA_SUGGESTION_PROMPT = "/llm-tools/schema-suggestion/prompt";
|
|
13
|
+
export declare const ENDPOINT_SCHEMA_SUGGESTION_TRANSLATE = "/llm-tools/schema-suggestion/translate";
|
|
6
14
|
export interface GenerateWranglingSchemaRequest {
|
|
7
15
|
/** Plain-language instruction for how the sheet should be reshaped. */
|
|
8
16
|
prompt: string;
|
|
@@ -60,6 +68,12 @@ export interface SuggestEntityCategoryRequest {
|
|
|
60
68
|
kind: 'category' | 'relationship';
|
|
61
69
|
/** Every already-existing entity category (or relationship, matching `kind`) in the project. */
|
|
62
70
|
existingCategories: ExistingCategoryForSuggestion[];
|
|
71
|
+
/**
|
|
72
|
+
* The languages the project works in. The candidate may be typed in any language; the term
|
|
73
|
+
* comes back English under `en` plus one entry per language asked for, with the candidate's
|
|
74
|
+
* own wording kept under the language it was written in. `en` is always implied.
|
|
75
|
+
*/
|
|
76
|
+
languages?: string[];
|
|
63
77
|
/** Project the request is scoped to. */
|
|
64
78
|
projectId: string;
|
|
65
79
|
}
|
|
@@ -70,14 +84,25 @@ export interface SuggestEntityCategoryMatch {
|
|
|
70
84
|
reasoning: string;
|
|
71
85
|
}
|
|
72
86
|
export interface SuggestEntityCategorySuggestion {
|
|
87
|
+
/** The English label — `labels['en']`, kept flat for callers that read one string. */
|
|
73
88
|
label: string;
|
|
89
|
+
/** The English definition — `definitions['en']`. */
|
|
74
90
|
definition: string;
|
|
91
|
+
/**
|
|
92
|
+
* The label per language: English under `en`, one entry per language the project asked for,
|
|
93
|
+
* and the candidate's own wording under the language it was written in. These become the
|
|
94
|
+
* term's `skos:prefLabel`s, so a German project keeps `Fachgebiet` beside `Discipline`.
|
|
95
|
+
*/
|
|
96
|
+
labels: Record<string, string>;
|
|
97
|
+
definitions: Record<string, string>;
|
|
75
98
|
/** IRI of the existing category/relationship this new one should nest under, if any. */
|
|
76
99
|
parentIri?: string;
|
|
77
100
|
reasoning: string;
|
|
78
101
|
}
|
|
79
102
|
export interface SuggestEntityCategoryResponse {
|
|
80
103
|
decision: 'match' | 'new';
|
|
104
|
+
/** The language the candidate turned out to be written in, when the model could tell. */
|
|
105
|
+
detectedLanguage?: string;
|
|
81
106
|
match?: SuggestEntityCategoryMatch;
|
|
82
107
|
suggestion?: SuggestEntityCategorySuggestion;
|
|
83
108
|
}
|
|
@@ -98,13 +123,205 @@ export interface SuggestEntityCategoryBatchRequest {
|
|
|
98
123
|
columns: ColumnToSuggest[];
|
|
99
124
|
/** Every already-existing entity category in the project. */
|
|
100
125
|
existingCategories: ExistingCategoryForSuggestion[];
|
|
126
|
+
/** As on the single-candidate request: the languages every proposed term comes back in. */
|
|
127
|
+
languages?: string[];
|
|
101
128
|
/** Project the request is scoped to. */
|
|
102
129
|
projectId: string;
|
|
103
130
|
}
|
|
104
131
|
export interface SuggestEntityCategoryBatchResponse {
|
|
105
132
|
/** One result per given column, in the same order. */
|
|
106
133
|
results: ColumnCategorySuggestionResult[];
|
|
134
|
+
/** The language the column headings turned out to be written in, when the model could tell. */
|
|
135
|
+
detectedLanguage?: string;
|
|
136
|
+
}
|
|
137
|
+
export interface SuggestFromProseRequest {
|
|
138
|
+
/** Project the request is scoped to. */
|
|
139
|
+
projectId: string;
|
|
140
|
+
/** Free-text description of the schema to build (or extend). */
|
|
141
|
+
prose: string;
|
|
142
|
+
/** The schema to extend, if one already exists. */
|
|
143
|
+
current?: ProjectSchema;
|
|
144
|
+
/** BCP-47 tags a proposed term is translated into. Pivot (`en`) always implied. */
|
|
145
|
+
languages?: string[];
|
|
146
|
+
}
|
|
147
|
+
export interface SuggestFromProseResponse {
|
|
148
|
+
schema: ProjectSchema;
|
|
149
|
+
notes?: string[];
|
|
150
|
+
}
|
|
151
|
+
export interface SuggestFromImagesRequest {
|
|
152
|
+
/** Project the request is scoped to. */
|
|
153
|
+
projectId: string;
|
|
154
|
+
/** Base64-encoded PNG bytes (no `data:` URL prefix), a handful of example-document pages. */
|
|
155
|
+
images: string[];
|
|
156
|
+
/** The schema to extend, if one already exists. */
|
|
157
|
+
current?: ProjectSchema;
|
|
158
|
+
/** BCP-47 tags a proposed term is translated into. Pivot (`en`) always implied. */
|
|
159
|
+
languages?: string[];
|
|
160
|
+
}
|
|
161
|
+
export type SuggestFromImagesResponse = SuggestFromProseResponse;
|
|
162
|
+
export interface ParseCodingSchemeRequest {
|
|
163
|
+
/** Project the request is scoped to. */
|
|
164
|
+
projectId: string;
|
|
165
|
+
/** Which field position within the code this segment occupies. */
|
|
166
|
+
position: number;
|
|
167
|
+
/** The label the person gave this segment. */
|
|
168
|
+
label: string;
|
|
169
|
+
/** The raw text (e.g. a legend or table) describing the segment's codes. */
|
|
170
|
+
text: string;
|
|
171
|
+
/**
|
|
172
|
+
* The languages the project works in; every code's gloss comes back in each of them. The
|
|
173
|
+
* legend's own language is filed on top whether or not it is one of these — see
|
|
174
|
+
* `detectedLanguage` on the response.
|
|
175
|
+
*/
|
|
176
|
+
languages?: string[];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* One candidate code parsed out of a coding scheme's legend text.
|
|
180
|
+
*
|
|
181
|
+
* `meaning` is the legend's own wording, untranslated — it is what the documents say. `labels`
|
|
182
|
+
* carries the same gloss per language, `en` included, once the text has been through
|
|
183
|
+
* `parseCodingScheme`.
|
|
184
|
+
*/
|
|
185
|
+
export interface CodingSchemeOption {
|
|
186
|
+
code: string;
|
|
187
|
+
meaning?: string;
|
|
188
|
+
labels?: Record<string, string>;
|
|
189
|
+
}
|
|
190
|
+
export interface ParseCodingSchemeResponse {
|
|
191
|
+
options: CodingSchemeOption[];
|
|
192
|
+
/**
|
|
193
|
+
* The language the legend turned out to be written in, as a two-letter code — detected rather
|
|
194
|
+
* than declared, since a pasted legend carries no language field. Stamp it on the scheme:
|
|
195
|
+
* `from-coding-scheme` uses it to decide which language the field labels are kept in.
|
|
196
|
+
*/
|
|
197
|
+
detectedLanguage?: string;
|
|
107
198
|
}
|
|
199
|
+
/**
|
|
200
|
+
* One positional field of a coding scheme as the wizard parses it — *before*
|
|
201
|
+
* it becomes a category. Distinct from `js/models`' `CodingSchemeField`,
|
|
202
|
+
* which is the same field *after*: this one carries the raw candidate codes
|
|
203
|
+
* (`options`), not yet a resolved category key.
|
|
204
|
+
*/
|
|
205
|
+
export interface RawCodingSchemeField {
|
|
206
|
+
position: number;
|
|
207
|
+
label: string;
|
|
208
|
+
description?: string;
|
|
209
|
+
options: CodingSchemeOption[];
|
|
210
|
+
pattern?: string;
|
|
211
|
+
labels?: Record<string, string>;
|
|
212
|
+
}
|
|
213
|
+
/** The wizard's own coding-scheme shape, ahead of `suggestFromCodingScheme` resolving it into categories. */
|
|
214
|
+
export interface RawCodingScheme {
|
|
215
|
+
name?: string;
|
|
216
|
+
/**
|
|
217
|
+
* Overrides the whole-code category's label, which otherwise defaults to `name` (e.g. a scheme
|
|
218
|
+
* named "Cuneco" gets a category labelled "Cuneco Code"). Set when the standard's own short code
|
|
219
|
+
* differs from its full name. Also feeds the key, unless `key` is set too.
|
|
220
|
+
*/
|
|
221
|
+
code?: string;
|
|
222
|
+
/** Overrides the whole-code category's key outright, bypassing the `ClassificationCode_<slug>` derivation entirely. */
|
|
223
|
+
key?: string;
|
|
224
|
+
language?: string;
|
|
225
|
+
samples: string[];
|
|
226
|
+
separator: string;
|
|
227
|
+
fields: RawCodingSchemeField[];
|
|
228
|
+
}
|
|
229
|
+
export interface SuggestFromCodingSchemeRequest {
|
|
230
|
+
/** Project the request is scoped to. */
|
|
231
|
+
projectId: string;
|
|
232
|
+
scheme: RawCodingScheme;
|
|
233
|
+
/** The schema to extend, if one already exists. */
|
|
234
|
+
current?: ProjectSchema;
|
|
235
|
+
/**
|
|
236
|
+
* The languages every proposed category's labels come back in; falls back to `current`'s. The
|
|
237
|
+
* scheme's own language (`scheme.language`, else detected) is filed on top of these, so a
|
|
238
|
+
* German scheme keeps `Fachgebiet` whether or not the project declared German.
|
|
239
|
+
*/
|
|
240
|
+
languages?: string[];
|
|
241
|
+
}
|
|
242
|
+
export interface SuggestFromCodingSchemeResponse {
|
|
243
|
+
schema: ProjectSchema;
|
|
244
|
+
notes?: string[];
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* One column of a document register as the model sees it: a heading and three counts.
|
|
248
|
+
*
|
|
249
|
+
* No values — those travel as whole rows (`SuggestFromColumnsRequest.rows`), because a
|
|
250
|
+
* register's columns are only legible together. What the counts say is the part no example can:
|
|
251
|
+
* `distinct` separates a five-value status column from a five-hundred-value taxonomy level
|
|
252
|
+
* whatever the rows happen to show.
|
|
253
|
+
*/
|
|
254
|
+
export interface ColumnCounts {
|
|
255
|
+
column: string;
|
|
256
|
+
/** Rows the file has, so a distinct count can be read as a ratio. */
|
|
257
|
+
rows: number;
|
|
258
|
+
/** Cells of this column that were empty. */
|
|
259
|
+
blanks?: number;
|
|
260
|
+
/** Distinct non-blank values in the whole column. */
|
|
261
|
+
distinct: number;
|
|
262
|
+
}
|
|
263
|
+
export interface SuggestFromColumnsRequest {
|
|
264
|
+
/** Project the request is scoped to. */
|
|
265
|
+
projectId: string;
|
|
266
|
+
columns: ColumnCounts[];
|
|
267
|
+
/**
|
|
268
|
+
* A few whole rows, picked as representative, keyed by heading. At most five are accepted.
|
|
269
|
+
*
|
|
270
|
+
* Whole rows rather than per-column lists because a value means what the values beside it say
|
|
271
|
+
* it means: `A1` next to a scale and a sheet number is a sheet size, and next to a discipline
|
|
272
|
+
* and a phase it is a code. Only the columns in `columns` — plus `fileColumn` — are carried; a
|
|
273
|
+
* column the user left out is left out of these rows too.
|
|
274
|
+
*/
|
|
275
|
+
rows?: Record<string, string>[];
|
|
276
|
+
/** The schema these columns are read against — the categories a column can *match*. */
|
|
277
|
+
current?: ProjectSchema;
|
|
278
|
+
/** The column naming the file itself, which is never a thing the file is about. */
|
|
279
|
+
fileColumn?: string;
|
|
280
|
+
/** BCP-47 tags a proposed term is translated into. Pivot (`en`) always implied. */
|
|
281
|
+
languages?: string[];
|
|
282
|
+
/** How many entity catalogues triage may open. Same meaning and default as `from-prose`. */
|
|
283
|
+
maxCatalogs?: number;
|
|
284
|
+
}
|
|
285
|
+
/** One column's outcome. `categoryKey` indexes into `schema.entityCategories`. */
|
|
286
|
+
export interface ColumnCategoryDecision {
|
|
287
|
+
column: string;
|
|
288
|
+
/** `catalog` is a curated term hydrated verbatim — always preferred over `new` when one fits. */
|
|
289
|
+
decision: 'match' | 'catalog' | 'new' | 'skip';
|
|
290
|
+
/** One sentence, for the person reviewing — present on the skips too. */
|
|
291
|
+
reason: string;
|
|
292
|
+
/** `match`: the existing category this column already is. */
|
|
293
|
+
matchedKey?: string;
|
|
294
|
+
/** `catalog` and `new`: the key of the category in `schema.entityCategories`. */
|
|
295
|
+
categoryKey?: string;
|
|
296
|
+
/** `catalog`: which catalogue the hydrated term came from. */
|
|
297
|
+
catalog?: string;
|
|
298
|
+
}
|
|
299
|
+
export interface SuggestFromColumnsResponse {
|
|
300
|
+
/** Exactly one per column given, in the same order. */
|
|
301
|
+
decisions: ColumnCategoryDecision[];
|
|
302
|
+
/** The proposed categories only — `current` is not folded in. */
|
|
303
|
+
schema: ProjectSchema;
|
|
304
|
+
notes: string[];
|
|
305
|
+
}
|
|
306
|
+
export interface SuggestPromptRequest {
|
|
307
|
+
/** Project the request is scoped to. */
|
|
308
|
+
projectId: string;
|
|
309
|
+
kind: 'category' | 'relation';
|
|
310
|
+
/** The term's key. */
|
|
311
|
+
key: string;
|
|
312
|
+
labels: Record<string, string>;
|
|
313
|
+
definition?: Record<string, string>;
|
|
314
|
+
}
|
|
315
|
+
export interface TranslateRequest {
|
|
316
|
+
/** Project the request is scoped to. */
|
|
317
|
+
projectId: string;
|
|
318
|
+
/** The word or phrase to translate. */
|
|
319
|
+
term: string;
|
|
320
|
+
/** The languages to translate into; pivot (`en`) always implied. */
|
|
321
|
+
languages: string[];
|
|
322
|
+
}
|
|
323
|
+
/** One entry per language asked for, plus the pivot. */
|
|
324
|
+
export type TranslateResponse = Record<string, string>;
|
|
108
325
|
/**
|
|
109
326
|
* Client for the llm-tools guarded-LLM endpoints — small, single-purpose
|
|
110
327
|
* backend calls that turn a prompt plus example data into a structured JSON
|
|
@@ -144,4 +361,49 @@ export declare class CueLlmTools {
|
|
|
144
361
|
* same new category twice under different names).
|
|
145
362
|
*/
|
|
146
363
|
suggestEntityCategoryBatch(request: SuggestEntityCategoryBatchRequest): Promise<SuggestEntityCategoryBatchResponse>;
|
|
364
|
+
/**
|
|
365
|
+
* Drafts a full {@link ProjectSchema} (or extends `current`) from a free-text
|
|
366
|
+
* description of the project's domain — the wizard's "describe it in prose" entry point.
|
|
367
|
+
*/
|
|
368
|
+
suggestFromProse(request: SuggestFromProseRequest): Promise<SuggestFromProseResponse>;
|
|
369
|
+
/**
|
|
370
|
+
* The same draft `suggestFromProse` produces, from a handful of example-document page images
|
|
371
|
+
* instead of a prose description — the wizard's "upload example files" entry point. The caller
|
|
372
|
+
* renders each page to PNG and base64-encodes it; this method only relays the bytes.
|
|
373
|
+
*/
|
|
374
|
+
suggestFromImages(request: SuggestFromImagesRequest): Promise<SuggestFromImagesResponse>;
|
|
375
|
+
/**
|
|
376
|
+
* Parses one positional segment of a client's numbering standard (e.g. a legend
|
|
377
|
+
* pasted from a table) into candidate codes, ready to become a {@link RawCodingSchemeField}.
|
|
378
|
+
*/
|
|
379
|
+
parseCodingScheme(request: ParseCodingSchemeRequest): Promise<ParseCodingSchemeResponse>;
|
|
380
|
+
/**
|
|
381
|
+
* Drafts a full {@link ProjectSchema} (or extends `current`) from a parsed
|
|
382
|
+
* {@link RawCodingScheme} — the wizard's "derive it from a numbering standard" entry point.
|
|
383
|
+
*/
|
|
384
|
+
suggestFromCodingScheme(request: SuggestFromCodingSchemeRequest): Promise<SuggestFromCodingSchemeResponse>;
|
|
385
|
+
/**
|
|
386
|
+
* Reads a document register's column headings as terms — which columns are categories the
|
|
387
|
+
* project already has, which name vocabularies it is missing, and which are not vocabularies
|
|
388
|
+
* at all.
|
|
389
|
+
*
|
|
390
|
+
* Send a profile, not a file: headings, counts and a sample of each column's distinct values.
|
|
391
|
+
* The caller already has a local answer from cue-ui's `sheetColumnsToProposal`; this one
|
|
392
|
+
* replaces it rather than merging with it, and what it adds is the part cardinality cannot
|
|
393
|
+
* see — that `Auftraggeber` is `Client` under another name, and that `Ebene 1`…`Ebene 4` are
|
|
394
|
+
* one taxonomy rather than four unrelated terms.
|
|
395
|
+
*/
|
|
396
|
+
suggestFromColumns(request: SuggestFromColumnsRequest): Promise<SuggestFromColumnsResponse>;
|
|
397
|
+
/**
|
|
398
|
+
* Drafts an extraction/classification prompt for one category or relation term
|
|
399
|
+
* from its labels (and optional definition) — unwraps the backend's `{ prompt }`
|
|
400
|
+
* envelope so callers get the string directly.
|
|
401
|
+
*/
|
|
402
|
+
suggestPrompt(request: SuggestPromptRequest): Promise<string>;
|
|
403
|
+
/**
|
|
404
|
+
* Translates one bare word or phrase into every requested language — no key, no
|
|
405
|
+
* definition, no merge against anything already there: for a caller that just has a
|
|
406
|
+
* string and wants it in more languages, e.g. a canonical's `value`.
|
|
407
|
+
*/
|
|
408
|
+
translate(request: TranslateRequest): Promise<TranslateResponse>;
|
|
147
409
|
}
|