@qaecy/cue-sdk 0.0.41 → 0.0.44

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/index.d.ts CHANGED
@@ -41,11 +41,13 @@ export type { ProjectTable } from './lib/tables';
41
41
  export { CueExtraction } from './lib/extraction';
42
42
  export type { ExtractionRequest, ExtractionResponse } from './lib/extraction';
43
43
  export { CueLlmTools } from './lib/llm-tools';
44
- export type { GenerateWranglingSchemaRequest, GenerateWranglingSchemaResponse } from './lib/llm-tools';
44
+ export type { GenerateWranglingSchemaRequest, GenerateWranglingSchemaResponse, ExistingCategoryForSuggestion, SuggestEntityCategoryRequest, SuggestEntityCategoryResponse, SuggestEntityCategoryMatch, SuggestEntityCategorySuggestion, ColumnToSuggest, ColumnCategorySuggestionResult, SuggestEntityCategoryBatchRequest, SuggestEntityCategoryBatchResponse, } from './lib/llm-tools';
45
45
  export { CueDataSources } from './lib/data-sources';
46
46
  export type { DataSourceRecord, XToRdfConfig, RmlXToRdfConfig, GraphXToRdfConfig, TypeMappingConfiguration, UploadDataSourceMode, UploadDataSourceResult, } from './lib/data-sources';
47
47
  export { CueGisSources } from './lib/gis-sources';
48
48
  export type { GisSourceRecord, GisSourceUploadFormat, GisSourceCrs } from './lib/gis-sources';
49
+ export { CueSemanticTemplate } from './lib/semantic-template';
50
+ export type { MutationResult as SemanticTemplateMutationResult, BatchMutationResult as SemanticTemplateBatchMutationResult, ContentCategoryInput, EntityCategoryInput, EntityRelationshipInput, } from './lib/semantic-template';
49
51
  export { CueContexts } from './lib/contexts';
50
52
  export type { ContextDoc, ContextItem, McpContext } from './lib/models';
51
53
  export { CueAppData } from './lib/app-data';
package/index.js CHANGED
@@ -1,23 +1,23 @@
1
- import { B as a, C as u, a as C, b as t, c as r, d as i, e as o, f as c, g as n, h as p, i as S, j as E, k as A, l as m, m as P, n as R, o as g, p as l, q as D, r as j, s as U, t as x, u as d, v as f, w as h, x as I, y, z as G, A as T, D as _, E as b, F as q, G as v, H as w, R as B, S as F, I as L, J as N } from "./document-filter-C0-xdpqp.js";
1
+ import { B as a, C as u, a as C, b as t, c as i, d as r, e as o, f as c, g as n, h as p, i as S, j as m, k as E, l as A, m as P, n as R, o as l, p as g, q as D, r as j, s as U, t as x, u as d, v as f, w as h, x as I, y as T, z as y, A as G, D as _, E as b, F as q, G as v, H as w, I as B, R as F, S as L, J as N, K as O } from "./document-filter-Cj0Yql1C.js";
2
2
  export {
3
3
  a as BASE_CURRENCY,
4
4
  u as Cue,
5
5
  C as CueAdmin,
6
6
  t as CueApi,
7
- r as CueAppData,
8
- i as CueApps,
7
+ i as CueAppData,
8
+ r as CueApps,
9
9
  o as CueAuth,
10
10
  c as CueCache,
11
11
  n as CueContexts,
12
12
  p as CueCurrency,
13
13
  S as CueDataSources,
14
- E as CueDmsApi,
15
- A as CueDocumentFilter,
16
- m as CueExtraction,
14
+ m as CueDmsApi,
15
+ E as CueDocumentFilter,
16
+ A as CueExtraction,
17
17
  P as CueGis,
18
18
  R as CueGisSources,
19
- g as CueIndexApi,
20
- l as CueLlmTools,
19
+ l as CueIndexApi,
20
+ g as CueLlmTools,
21
21
  D as CueMcp,
22
22
  j as CuePrivileges,
23
23
  U as CueProcessingApi,
@@ -26,16 +26,17 @@ export {
26
26
  f as CueProjectEntities,
27
27
  h as CueProjectSchema,
28
28
  I as CueProjectView,
29
- y as CueProjects,
30
- G as CueRequestError,
31
- T as CueSignUp,
32
- _ as CueSignal,
33
- b as CueStorage,
34
- q as CueSyncApi,
35
- v as CueTables,
36
- w as CueUserSettings,
37
- B as REQUIRED_ROLES,
38
- F as SUPPORTED_CURRENCIES,
39
- L as configureScanWasm,
40
- N as cueComputed
29
+ T as CueProjects,
30
+ y as CueRequestError,
31
+ G as CueSemanticTemplate,
32
+ _ as CueSignUp,
33
+ b as CueSignal,
34
+ q as CueStorage,
35
+ v as CueSyncApi,
36
+ w as CueTables,
37
+ B as CueUserSettings,
38
+ F as REQUIRED_ROLES,
39
+ L as SUPPORTED_CURRENCIES,
40
+ N as configureScanWasm,
41
+ O as cueComputed
41
42
  };
package/lib/api.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { CueBlobStorage } from 'js-databases';
1
2
  import { CueAuth } from './auth';
2
3
  import { SearchRequest, SearchResponse, ShaclValidationReport, UnitsConsumedDto } from './models';
3
4
  import { CueProjects } from './project';
@@ -15,6 +16,7 @@ import { CueDmsApi } from './dms';
15
16
  import { CueLlmTools } from './llm-tools';
16
17
  import { CueDataSources } from './data-sources';
17
18
  import { CueGisSources } from './gis-sources';
19
+ import { CueSemanticTemplate } from './semantic-template';
18
20
  export declare class CueApi {
19
21
  private readonly _auth;
20
22
  private readonly _gatewayUrl;
@@ -46,11 +48,14 @@ export declare class CueApi {
46
48
  /** Project-scoped GIS sources — user-uploaded GeoJSON/KML/Shapefile feature sets, returned by
47
49
  * `cue.gis` under the 'custom' category alongside every other GIS category. */
48
50
  readonly gisSources: CueGisSources;
51
+ /** Mutates a project's custom extraction/classification schema (content categories, entity
52
+ * categories, entity relationships) and reloads its `databases-cue` schema graph. */
53
+ readonly semanticTemplate: CueSemanticTemplate;
49
54
  /** Active language used for language-sensitive SPARQL queries across all project classes. */
50
55
  language: string;
51
56
  /** Updates the active language. All project classes (`CueProjectSchema`, `CueProjectDocuments`, `CueProjectEntities`) read this at query time. */
52
57
  setLanguage(lang: string): void;
53
- constructor(_auth: CueAuth, _gatewayUrl: string, projects: CueProjects, sync?: CueSyncApi | undefined);
58
+ constructor(_auth: CueAuth, _gatewayUrl: string, projects: CueProjects, sync?: CueSyncApi | undefined, blob?: CueBlobStorage);
54
59
  /**
55
60
  * Returns standard authentication headers for the current user.
56
61
  * Useful when calling Cue-backed services directly (e.g. the GIS proxy).
@@ -64,8 +69,14 @@ export declare class CueApi {
64
69
  /**
65
70
  * Execute a SPARQL query against the project's triplestore.
66
71
  * The user must be authenticated before calling this.
72
+ *
73
+ * The gateway resolves which graph backend (qlever, cue, …) actually serves
74
+ * the query per-project — `graphType` here only needs to distinguish legacy
75
+ * Fuseki, which lives on its own static Kong route rather than that
76
+ * per-project routing. Pass it explicitly if the caller already knows;
77
+ * otherwise it's looked up from the project's own settings.
67
78
  */
68
- sparql(query: string, projectId: string, graphType?: string): Promise<unknown>;
79
+ sparql(query: string, projectId: string, graphType?: 'fuseki' | 'qlever'): Promise<unknown>;
69
80
  /**
70
81
  * Validate a SHACL shape against the project's triplestore.
71
82
  *
@@ -79,7 +90,7 @@ export declare class CueApi {
79
90
  shacl(shape: string, projectId: string, options?: {
80
91
  format?: 'json-ld' | 'turtle';
81
92
  verbose?: boolean;
82
- graphType?: string;
93
+ graphType?: 'fuseki' | 'qlever';
83
94
  }): Promise<ShaclValidationReport | string>;
84
95
  /**
85
96
  * Per-extension credit rates for `tier` (e.g. `{ pdf: 4, ifc: 2, dwg: 2 }`),
package/lib/cue.d.ts CHANGED
@@ -111,7 +111,7 @@ export declare class Cue {
111
111
  */
112
112
  createProjectEntities(projectId: string, opts?: {
113
113
  rdfBase?: string;
114
- graphType?: string;
114
+ graphType?: 'fuseki' | 'qlever';
115
115
  verbose?: boolean;
116
116
  }): CueProjectEntities;
117
117
  /**
@@ -128,7 +128,7 @@ export declare class Cue {
128
128
  createProjectDocuments(projectId: string, opts?: {
129
129
  language?: string;
130
130
  rdfBase?: string;
131
- graphType?: string;
131
+ graphType?: 'fuseki' | 'qlever';
132
132
  verbose?: boolean;
133
133
  }): CueProjectDocuments;
134
134
  }
@@ -1,5 +1,6 @@
1
+ import { CueBlobStorage } from 'js-databases';
1
2
  import { CueAuth } from './auth';
2
- export type XToRdfConfig = RmlXToRdfConfig | GraphXToRdfConfig | DecompositionConfig;
3
+ export type XToRdfConfig = RmlXToRdfConfig | GraphXToRdfConfig | DecompositionConfig | SheetXToRdfConfig;
3
4
  interface XToRdfConfigBase {
4
5
  /** Steps run on the transform's output, in order — see `XToRdfPostProcessingStep`. */
5
6
  postProcessing?: XToRdfPostProcessingStep[];
@@ -51,6 +52,47 @@ export interface DecompositionConfig extends XToRdfConfigBase {
51
52
  */
52
53
  levels: Record<string, unknown>[];
53
54
  }
55
+ export interface SheetXToRdfConfig extends XToRdfConfigBase {
56
+ type: 'sheet';
57
+ mapping: SheetMappingConfiguration;
58
+ }
59
+ /**
60
+ * How a spreadsheet's columns become RDF: every column is either ignored, an entity — minted
61
+ * onto the same deterministic-IRI scheme `graph`/`decomposition` use
62
+ * (`<rdfBase><projectId>/<uuidv5(value+categoryIri)>`) — or an attribute of one entity column (a
63
+ * `qcy:Property` node linked via `qcy:hasProperty`). A relationship connects two entity columns
64
+ * via a chosen predicate, read off the same row. Unlike `wizardConfig`/`levels` above, this is
65
+ * NOT opaque to the backend — it's the actual input the sheet transform interprets row by row.
66
+ */
67
+ export interface SheetMappingConfiguration {
68
+ id?: string;
69
+ name: string;
70
+ columnRoles: Record<string, SheetColumnRole>;
71
+ relationMappings: SheetRelationMapping[];
72
+ fileLinkage?: SheetFileLinkage | null;
73
+ }
74
+ export type SheetColumnRole = {
75
+ kind: 'unmapped';
76
+ } | {
77
+ kind: 'entity';
78
+ categoryIri: string;
79
+ } | {
80
+ kind: 'attribute';
81
+ entityColumn: string;
82
+ label: string;
83
+ };
84
+ export interface SheetRelationMapping {
85
+ sourceColumn: string;
86
+ targetColumn: string;
87
+ predicateIri: string;
88
+ /** True when the predicate points from target to source instead of source to target. */
89
+ reversed?: boolean;
90
+ }
91
+ /** "Rows represent files" — a sheet-wide special case, not a per-column role. */
92
+ export interface SheetFileLinkage {
93
+ filePathColumn: string;
94
+ md5Column?: string;
95
+ }
54
96
  /**
55
97
  * A step applied to a transform's *output*, after the CONSTRUCT query (or RML mapping) has run.
56
98
  *
@@ -139,14 +181,25 @@ export interface DataSourceProgressEvent {
139
181
  export declare class CueDataSources {
140
182
  private readonly _auth;
141
183
  private readonly _gatewayUrl;
142
- constructor(_auth: CueAuth, _gatewayUrl: string);
184
+ private readonly _blob?;
185
+ constructor(_auth: CueAuth, _gatewayUrl: string, _blob?: CueBlobStorage | undefined);
143
186
  createDataSource(projectId: string, name: string, config: XToRdfConfig): Promise<DataSourceRecord>;
144
187
  updateDataSource(projectId: string, id: string, updates: {
145
188
  name?: string;
146
189
  config?: XToRdfConfig;
147
190
  }): Promise<DataSourceRecord>;
148
- /** Hard delete — also removes the data source's triples from the graph/ledger. */
149
- deleteDataSource(projectId: string, id: string): Promise<void>;
191
+ /**
192
+ * Hard delete — also removes the data source's triples from the graph/ledger. This fetches the
193
+ * whole named graph and round-trips to the ledger/graph store, which can take tens of seconds;
194
+ * the endpoint streams NDJSON progress while that's in flight — pass `onProgress` to receive it
195
+ * (see `uploadData`'s doc comment for the wire format). Still bounded by a client-side timeout
196
+ * covering the server's own bounded retries against the ledger/graph store (30s x up to 3
197
+ * retries each, for both) plus normal request/response overhead, in case the stream stalls
198
+ * with no further progress.
199
+ */
200
+ deleteDataSource(projectId: string, id: string, onProgress?: (event: DataSourceProgressEvent) => void): Promise<{
201
+ removed: number;
202
+ }>;
150
203
  /**
151
204
  * Uploads new data to be transformed by the data source's stored config and
152
205
  * committed into its named graph. `mode: 'replace'` swaps out everything
@@ -156,11 +209,13 @@ export declare class CueDataSources {
156
209
  * they're all loaded into one shared graph server-side before the stored
157
210
  * CONSTRUCT query runs against it. `type: 'rml'` configs expect exactly one.
158
211
  *
159
- * The endpoint streams NDJSON progress while the upload is in flight — pass
160
- * `onProgress` to receive it. The call still resolves/rejects only once, with
161
- * the final result or an `Error` built from the stream's `error` line (a
162
- * non-2xx HTTP status, e.g. an auth/guard rejection before the handler even
163
- * runs, is still thrown from `response.ok` as before).
212
+ * Each file is uploaded straight to storage first (see `_stageFiles`) — the request that
213
+ * follows carries only small file references, never the bytes, so file size never runs into
214
+ * Cloud Run's request-size limit. `onProgress` receives `phase: 'uploading'` events for that
215
+ * step, then the endpoint's usual NDJSON processing-progress events once the notify request is
216
+ * in flight. The call still resolves/rejects only once, with the final result or an `Error`
217
+ * built from the stream's `error` line (a non-2xx HTTP status, e.g. an auth/guard rejection
218
+ * before the handler even runs, is still thrown from `response.ok` as before).
164
219
  */
165
220
  uploadData(projectId: string, id: string, files: Blob[], mode: UploadDataSourceMode, onProgress?: (event: DataSourceProgressEvent) => void): Promise<UploadDataSourceResult>;
166
221
  /**
@@ -168,12 +223,23 @@ export declare class CueDataSources {
168
223
  * without creating a data source or writing anything to the graph/ledger —
169
224
  * for previewing a transform (e.g. while building a CONSTRUCT query or RML
170
225
  * mapping) before saving it. Same transform code as `uploadData`, so a
171
- * preview never drifts from what an actual upload would produce. Streams
172
- * progress the same way — see `uploadData`'s doc comment.
226
+ * preview never drifts from what an actual upload would produce. Uploads
227
+ * `files` to storage first and streams progress the same way — see
228
+ * `uploadData`'s doc comment.
173
229
  */
174
230
  previewTransform(projectId: string, config: XToRdfConfig, files: Blob[], onProgress?: (event: DataSourceProgressEvent) => void): Promise<{
175
231
  turtle: string;
176
232
  }>;
233
+ /**
234
+ * Uploads every file straight to the raw bucket's `${projectId}/_tmp-uploads/` prefix (server
235
+ * deletes each one right after processing it — see writers-commands' `_withTempFiles`), so
236
+ * `uploadData`/`previewTransform`'s own request only ever carries small JSON references —
237
+ * bytes never cross Cloud Run's request-size cap, no matter how large the file. Reports
238
+ * upload-byte progress through `onProgress` as `phase: 'uploading'`, aggregated across every
239
+ * file in the batch (not most-recent-file-wins) since callers pass everything to `uploadData`
240
+ * in one call.
241
+ */
242
+ private _stageFiles;
177
243
  /** Reads an NDJSON response (`{type:'progress',...}` lines, then one `{type:'result',...}`
178
244
  * or `{type:'error',...}` line), forwarding progress events to `onProgress` and
179
245
  * resolving/rejecting with the terminal event. The HTTP status alone can't signal
@@ -27,7 +27,7 @@ export declare class CueDocumentFilter {
27
27
  private readonly _api;
28
28
  private readonly _projectId;
29
29
  private readonly _graphType?;
30
- constructor(_api: CueApi, _projectId: string, _graphType?: string | undefined);
30
+ constructor(_api: CueApi, _projectId: string, _graphType?: "fuseki" | "qlever" | undefined);
31
31
  /**
32
32
  * Returns which mime, content and entity-category options are available among
33
33
  * documents that satisfy `applied`. Pass an empty object (or omit) to get
@@ -52,7 +52,7 @@ export declare class CueProjectDocuments {
52
52
  readonly projectDocumentsData: ReadonlySignal<ProjectDocumentsData>;
53
53
  constructor(_api: CueApi, _projectId: string, language?: string,
54
54
  /** Override the RDF resource base URL. Defaults to `https://cue.qaecy.com/r/`. */
55
- rdfBase?: string, _graphType?: string | undefined, _verbose?: boolean);
55
+ rdfBase?: string, _graphType?: "fuseki" | "qlever" | undefined, _verbose?: boolean);
56
56
  /**
57
57
  * Resets all document state. Call when the active project changes.
58
58
  * Follow with `fetchOverview()` once the triplestore is ready.
package/lib/entities.d.ts CHANGED
@@ -70,7 +70,7 @@ export declare class CueProjectEntities {
70
70
  readonly entityGraph: ReadonlySignal<ProjectEntitiesData | undefined>;
71
71
  constructor(_api: CueApi, _projectId: string,
72
72
  /** Override the RDF resource base URL. Defaults to `https://cue.qaecy.com/r/`. */
73
- rdfBase?: string, _graphType?: string | undefined, _verbose?: boolean);
73
+ rdfBase?: string, _graphType?: "fuseki" | "qlever" | undefined, _verbose?: boolean);
74
74
  /**
75
75
  * Constructs the full RDF IRI for the given entity UUID.
76
76
  * Use this to bridge the UUID-based batch APIs and the IRI-based per-entity APIs.
@@ -1,6 +1,8 @@
1
1
  import { CueAuth } from './auth';
2
2
  export declare const ENDPOINT_WRANGLING_SCHEMA_GENERATE = "/llm-tools/wrangling-schema/generate";
3
3
  export declare const ENDPOINT_WRANGLING_SCHEMA_REFINE = "/llm-tools/wrangling-schema/refine";
4
+ export declare const ENDPOINT_ENTITY_CATEGORY_SUGGEST = "/llm-tools/entity-category-suggestion/suggest";
5
+ export declare const ENDPOINT_ENTITY_CATEGORY_SUGGEST_BATCH = "/llm-tools/entity-category-suggestion/suggest-batch";
4
6
  export interface GenerateWranglingSchemaRequest {
5
7
  /** Plain-language instruction for how the sheet should be reshaped. */
6
8
  prompt: string;
@@ -26,6 +28,11 @@ export interface RefineWranglingSchemaRequest {
26
28
  currentRules: Record<string, unknown>[];
27
29
  /** The new, follow-up instruction. */
28
30
  prompt: string;
31
+ /**
32
+ * How the follow-up instruction should treat `currentRules`: "append" only adds
33
+ * rules for what it describes, "change" revises whichever current rules it concerns.
34
+ */
35
+ mode: 'append' | 'change';
29
36
  /** Column names available in the sheet. */
30
37
  columns: string[];
31
38
  /** A handful of real rows, given as worked examples for the model. */
@@ -37,6 +44,67 @@ export interface RefineWranglingSchemaResponse {
37
44
  /** The complete, updated rule set — a replacement, not a diff. Same shape as `generate`'s. */
38
45
  rules: Record<string, unknown>[];
39
46
  }
47
+ /** An already-existing entity category/relationship the candidate can be matched against or nested under. */
48
+ export interface ExistingCategoryForSuggestion {
49
+ iri: string;
50
+ label: string;
51
+ definition?: string;
52
+ /** IRI of the parent category/relationship, if nested. */
53
+ parent?: string;
54
+ }
55
+ export interface SuggestEntityCategoryRequest {
56
+ /** The label the person typed for the new category/relationship they want to add. */
57
+ label: string;
58
+ /** Optional free-text description, if the person gave one. */
59
+ description?: string;
60
+ kind: 'category' | 'relationship';
61
+ /** Every already-existing entity category (or relationship, matching `kind`) in the project. */
62
+ existingCategories: ExistingCategoryForSuggestion[];
63
+ /** Project the request is scoped to. */
64
+ projectId: string;
65
+ }
66
+ export interface SuggestEntityCategoryMatch {
67
+ /** IRI of the existing category/relationship this candidate matches — one of the IRIs given in `existingCategories`. */
68
+ iri: string;
69
+ confidence: number;
70
+ reasoning: string;
71
+ }
72
+ export interface SuggestEntityCategorySuggestion {
73
+ label: string;
74
+ definition: string;
75
+ /** IRI of the existing category/relationship this new one should nest under, if any. */
76
+ parentIri?: string;
77
+ reasoning: string;
78
+ }
79
+ export interface SuggestEntityCategoryResponse {
80
+ decision: 'match' | 'new';
81
+ match?: SuggestEntityCategoryMatch;
82
+ suggestion?: SuggestEntityCategorySuggestion;
83
+ }
84
+ /** A sheet column not yet assigned a role, plus a few real values to seed the model. */
85
+ export interface ColumnToSuggest {
86
+ column: string;
87
+ sampleValues?: string[];
88
+ }
89
+ export interface ColumnCategorySuggestionResult {
90
+ column: string;
91
+ /** "skip" — this column doesn't look like a distinct entity and is left unmapped. */
92
+ decision: 'skip' | 'match' | 'new';
93
+ match?: SuggestEntityCategoryMatch;
94
+ suggestion?: SuggestEntityCategorySuggestion;
95
+ }
96
+ export interface SuggestEntityCategoryBatchRequest {
97
+ /** Every currently-unmapped column, each with a few real sample values. */
98
+ columns: ColumnToSuggest[];
99
+ /** Every already-existing entity category in the project. */
100
+ existingCategories: ExistingCategoryForSuggestion[];
101
+ /** Project the request is scoped to. */
102
+ projectId: string;
103
+ }
104
+ export interface SuggestEntityCategoryBatchResponse {
105
+ /** One result per given column, in the same order. */
106
+ results: ColumnCategorySuggestionResult[];
107
+ }
40
108
  /**
41
109
  * Client for the llm-tools guarded-LLM endpoints — small, single-purpose
42
110
  * backend calls that turn a prompt plus example data into a structured JSON
@@ -61,4 +129,19 @@ export declare class CueLlmTools {
61
129
  * than starts over.
62
130
  */
63
131
  refineWranglingSchema(request: RefineWranglingSchemaRequest): Promise<RefineWranglingSchemaResponse>;
132
+ /**
133
+ * Given a label (and optional description) for a new entity category or relationship, decides
134
+ * whether it already exists in the project's ontology under a different name/wording — so a
135
+ * person doesn't have to eyeball a long list themselves — or suggests a well-formed new one,
136
+ * including a parent nested under an existing category/relationship when that fits.
137
+ */
138
+ suggestEntityCategory(request: SuggestEntityCategoryRequest): Promise<SuggestEntityCategoryResponse>;
139
+ /**
140
+ * Given every currently-unmapped column in a sheet (name plus a few real values) and the
141
+ * project's existing entity categories, decides for each one whether it should stay unmapped,
142
+ * map to an existing category, or become a well-formed new one — one call covering every
143
+ * column at once, so the model can also stay consistent across them (e.g. not suggesting the
144
+ * same new category twice under different names).
145
+ */
146
+ suggestEntityCategoryBatch(request: SuggestEntityCategoryBatchRequest): Promise<SuggestEntityCategoryBatchResponse>;
64
147
  }
package/lib/models.d.ts CHANGED
@@ -115,6 +115,26 @@ export interface McpContext {
115
115
  id: string;
116
116
  text: string;
117
117
  }
118
+ /**
119
+ * Which service owns this project's INDEX — i.e. who applies writes to the
120
+ * graph/vector/FTS trio and owns the rebuild lifecycle for them.
121
+ *
122
+ * Deliberately a sibling of `graph`, not a new `graph.type` value: `cue` is not
123
+ * a graph backend. `databases-cue` owns all three engines, so `graph.type:
124
+ * 'cue'` would say "the graph lives at cue" while leaving vector and FTS
125
+ * pointed at `writers-index` — two owners for one project, which is the exact
126
+ * split this field exists to prevent. See the monorepo's
127
+ * `apps/databases/cue/PLAN.md` §9b.
128
+ */
129
+ export type IndexService = 'writers-index' | 'cue';
130
+ export interface IndexSettings {
131
+ service: IndexService;
132
+ /**
133
+ * Optional address override. Omitted means "the deployment's configured
134
+ * endpoint for `service`" — mirrors how `graph.uri` relates to `graph.type`.
135
+ */
136
+ uri?: string;
137
+ }
118
138
  export interface ProjectSettings {
119
139
  views?: Array<{
120
140
  id: string;
@@ -125,8 +145,22 @@ export interface ProjectSettings {
125
145
  type: 'qlever' | 'fuseki';
126
146
  uri?: string;
127
147
  };
148
+ /**
149
+ * Absent means `writers-index` — every project predating this field is on it,
150
+ * so the default has to be the status quo, not the new service.
151
+ */
152
+ index?: IndexSettings;
128
153
  /** Processing tier determining credit costs. Defaults to "l" if not set. */
129
154
  tier?: 's' | 'm' | 'l';
155
+ /**
156
+ * Gzip-compress eligible raw uploads for this project (see `gzip-steps.md`
157
+ * Phase 3 — per-project rollout gate, not a global switch). Absent/false
158
+ * means uploads stay uncompressed, which must stay the default until a
159
+ * project has been verified end-to-end. No admin-panel UI toggles this
160
+ * today (same as `tier` on an existing project) — set it directly on the
161
+ * project's Firestore doc.
162
+ */
163
+ gzipEnabled?: boolean;
130
164
  }
131
165
  /** One daily snapshot in `QleverStats.history` — a calendar day this index's stats were (re)computed. */
132
166
  export interface QleverStatsHistoryEntry {
@@ -4,12 +4,14 @@ import { CueProjectEntities } from './entities';
4
4
  import { CueProjectDocuments } from './documents';
5
5
  import { ReadonlySignal } from './signal';
6
6
  import { SearchOptions, SearchResponse, CategoryDef, RelationshipDef, EntityDetailedData, EntityRelationships, ProjectEntitiesData, DocumentInfo, ProjectDocumentsData } from './models';
7
+ import { ContentCategoryInput, EntityCategoryInput, EntityRelationshipInput } from './semantic-template';
7
8
  export interface CueProjectViewOptions {
8
9
  language: string;
9
10
  /** Override the RDF resource base URL. Defaults to `https://cue.qaecy.com/r/`. */
10
11
  rdfBase?: string;
11
- /** Graph engine type from projectSettings.graph.type (e.g. 'qlever' or 'fuseki'). */
12
- graphType?: string;
12
+ /** Graph engine type ('qlever' or legacy 'fuseki'). No longer read from the
13
+ * project document — see project-migration.md §4.3. */
14
+ graphType?: 'fuseki' | 'qlever';
13
15
  /** Enable verbose debug logging for entity and document fetch stats. */
14
16
  verbose?: boolean;
15
17
  }
@@ -60,6 +62,12 @@ export declare class CueProjectView {
60
62
  readonly searchResults: ReadonlySignal<SearchResponse | undefined>;
61
63
  private _destroyed;
62
64
  constructor(_api: CueApi, _projectId: string, { language, rdfBase, graphType, verbose }: CueProjectViewOptions);
65
+ /** Creates a new content category, appending it to `availableContentCategories` on success. */
66
+ createContentCategory(item: ContentCategoryInput): Promise<CategoryDef | null>;
67
+ /** Creates a new entity category, appending it to `availableEntityCategories` on success. */
68
+ createEntityCategory(item: EntityCategoryInput): Promise<CategoryDef | null>;
69
+ /** Creates a new entity relationship, appending it to `availableEntityRelationships` on success. */
70
+ createEntityRelationship(item: EntityRelationshipInput): Promise<RelationshipDef | null>;
63
71
  /**
64
72
  * Lazily batch-fetch core data (label + categories) for the given entity UUIDs.
65
73
  * Already-fetched UUIDs are skipped. Populates `entityInfoMap`.
package/lib/schema.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { CueApi } from './api';
2
2
  import { ReadonlySignal } from './signal';
3
3
  import { CategoryDef, RelationshipDef } from './models';
4
+ import { ContentCategoryInput, EntityCategoryInput, EntityRelationshipInput } from './semantic-template';
4
5
  /**
5
6
  * Holds the schema for a single project: available content categories,
6
7
  * entity categories, and entity relationship types.
@@ -49,7 +50,7 @@ export declare class CueProjectSchema {
49
50
  * completed (or failed). Await this before reading signal values imperatively.
50
51
  */
51
52
  readonly ready: Promise<void>;
52
- constructor(_api: CueApi, _projectId: string, language: string, _graphType?: string | undefined, verbose?: boolean);
53
+ constructor(_api: CueApi, _projectId: string, language: string, _graphType?: "fuseki" | "qlever" | undefined, verbose?: boolean);
53
54
  /** Returns the currently active language. */
54
55
  get language(): string;
55
56
  /**
@@ -63,6 +64,33 @@ export declare class CueProjectSchema {
63
64
  * Useful when the triplestore data has changed.
64
65
  */
65
66
  refresh(): Promise<void>;
67
+ /**
68
+ * Creates a new content category via `cue.api.semanticTemplate` and, on success,
69
+ * appends it to {@link availableContentCategories} in place — no `refresh()`
70
+ * needed for it to show up in every subscriber.
71
+ */
72
+ createContentCategory(item: ContentCategoryInput): Promise<CategoryDef | null>;
73
+ /**
74
+ * Creates a new entity category via `cue.api.semanticTemplate` and, on success,
75
+ * appends it to {@link availableEntityCategories} in place — no `refresh()`
76
+ * needed for it to show up in every subscriber.
77
+ */
78
+ createEntityCategory(item: EntityCategoryInput): Promise<CategoryDef | null>;
79
+ /**
80
+ * Creates a new entity relationship via `cue.api.semanticTemplate` and, on
81
+ * success, appends it to {@link availableEntityRelationships} in place — no
82
+ * `refresh()` needed for it to show up in every subscriber.
83
+ */
84
+ createEntityRelationship(item: EntityRelationshipInput): Promise<RelationshipDef | null>;
85
+ /**
86
+ * Turns a successful create-mutation result into a {@link CategoryDef} and
87
+ * appends it to both the cached language-independent snapshot and the live
88
+ * signal. Updating `_snapshot` too (not just the signal) matters: it's what
89
+ * `setLanguage()`/`_apply()` re-derive from, so skipping it would make the
90
+ * appended item vanish on the next language switch. Returns `null` when the
91
+ * mutation failed (no IRI was assigned).
92
+ */
93
+ private _appendCreated;
66
94
  private _load;
67
95
  /**
68
96
  * Fetches the schema once. On QLever the pre-computed `schemas` materialized
@@ -0,0 +1,63 @@
1
+ import { CueAuth } from './auth';
2
+ export interface MutationResult {
3
+ message: string;
4
+ success: boolean;
5
+ insertCount?: number;
6
+ iri?: string;
7
+ errorCode?: string;
8
+ }
9
+ export interface BatchMutationResult {
10
+ results: MutationResult[];
11
+ successCount: number;
12
+ failureCount: number;
13
+ }
14
+ export interface ContentCategoryInput {
15
+ value: string;
16
+ namespace: [string, string];
17
+ description: string;
18
+ parent?: string;
19
+ regex?: string;
20
+ enum?: string[];
21
+ enumNamespace?: [string, string];
22
+ label?: Record<string, string>;
23
+ definition?: Record<string, string>;
24
+ comment?: string;
25
+ }
26
+ export interface EntityCategoryInput extends ContentCategoryInput {
27
+ document_type_constraints?: string[];
28
+ }
29
+ /** `type` is not part of the input — the server always sets it to `object_property`. */
30
+ export interface EntityRelationshipInput extends EntityCategoryInput {
31
+ sources: string[];
32
+ targets: string[];
33
+ }
34
+ /**
35
+ * Client for writers-commands' semantic-template CRUD endpoints — persists a
36
+ * project's custom extraction/classification schema (content categories,
37
+ * entity categories, entity relationships) and reloads the project's
38
+ * `databases-cue` schema graph after every mutation.
39
+ *
40
+ * Exposed as `cue.api.semanticTemplate`.
41
+ */
42
+ export declare class CueSemanticTemplate {
43
+ private readonly _auth;
44
+ private readonly _gatewayUrl;
45
+ constructor(_auth: CueAuth, _gatewayUrl: string);
46
+ createContentCategory(projectId: string, item: ContentCategoryInput): Promise<MutationResult>;
47
+ createContentCategoryBatch(projectId: string, items: ContentCategoryInput[]): Promise<BatchMutationResult>;
48
+ deleteContentCategory(projectId: string, value: string): Promise<MutationResult>;
49
+ deleteContentCategoryBatch(projectId: string, values: string[]): Promise<BatchMutationResult>;
50
+ createEntityCategory(projectId: string, item: EntityCategoryInput): Promise<MutationResult>;
51
+ createEntityCategoryBatch(projectId: string, items: EntityCategoryInput[]): Promise<BatchMutationResult>;
52
+ deleteEntityCategory(projectId: string, value: string): Promise<MutationResult>;
53
+ deleteEntityCategoryBatch(projectId: string, values: string[]): Promise<BatchMutationResult>;
54
+ createEntityRelationship(projectId: string, item: EntityRelationshipInput): Promise<MutationResult>;
55
+ createEntityRelationshipBatch(projectId: string, items: EntityRelationshipInput[]): Promise<BatchMutationResult>;
56
+ deleteEntityRelationship(projectId: string, value: string): Promise<MutationResult>;
57
+ deleteEntityRelationshipBatch(projectId: string, values: string[]): Promise<BatchMutationResult>;
58
+ /** Re-pushes the project's currently stored template into its `databases-cue` schema graph, without mutating it. */
59
+ reloadSchema(projectId: string): Promise<MutationResult>;
60
+ private _post;
61
+ private _delete;
62
+ private _errorMessage;
63
+ }
package/lib/sync.d.ts CHANGED
@@ -26,6 +26,13 @@ export declare class CueSyncApi {
26
26
  private _pendingSpaceId;
27
27
  private _flushTimer;
28
28
  private _legacy;
29
+ /**
30
+ * `projectSettings.gzipEnabled` per space, populated once by
31
+ * `initBrowserSync` so `syncBrowserFile` (called once per dropped file,
32
+ * often dozens concurrently) doesn't re-fetch the project over the gateway
33
+ * on every single file.
34
+ */
35
+ private readonly _gzipEnabledBySpace;
29
36
  constructor(_auth: CueAuth, _projects: CueProjects, _blob: CueBlobStorage, _gatewayUrl: string);
30
37
  /** @internal Injected by CueApi after construction to avoid circular dependency. */
31
38
  _bindApi(api: CueApi): void;