@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/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export { CueSignUp, CueRequestError } from './lib/signup';
8
8
  export type { OrgSignUpPayload, OrgSignUpPlan } from './lib/signup';
9
9
  export { CueApi } from './lib/api';
10
10
  export { CueIndexApi } from './lib/index-api';
11
+ export type { MigrateAllProgress, MigrateAllResult } from './lib/index-api';
11
12
  export { CueMcp } from './lib/mcp';
12
13
  export type { McpCallOptions } from './lib/mcp';
13
14
  export type { IndexSearchRequest, IndexItem, IndexSearchResponse, IndexFilterOption, IndexAppliedFilters, AvailableFiltersResponse, SearchFilter, DocumentFilterOption, AvailableDocumentFilters, } from './lib/models';
@@ -23,6 +24,7 @@ export { CueProjectDocuments } from './lib/documents';
23
24
  export { CueProjectView } from './lib/project-view';
24
25
  export type { CueProjectViewOptions } from './lib/project-view';
25
26
  export { CueProjects } from './lib/project';
27
+ export type { ProjectUpdate } from './lib/project';
26
28
  export { CueProfile } from './lib/profile';
27
29
  export { CueAdmin } from './lib/admin';
28
30
  export type { AdminOrgSearchResult, AdminUserSearchResult, AdminProjectSearchResult, AdminUserOrgSummary, AdminUserProjectSummary, AdminUserDetail, AdminDeletedUserOrgRef, AdminDeletedUserProjectRef, AdminDeletedUserSummary, AdminRestoreUserResult, } from './lib/models';
@@ -34,20 +36,24 @@ export { CueCache } from './lib/cache';
34
36
  export type { QueryCacheEntry } from './lib/cache';
35
37
  export { CueCurrency, SUPPORTED_CURRENCIES, BASE_CURRENCY } from './lib/currency';
36
38
  export type { SupportedCurrency, CurrencyRates } from './lib/currency';
37
- export type { CueSdkConfig, SsoProvider, PasswordCredentials, SearchRequest, SearchResponse, SearchSource, SearchOptions, ProjectData, ProjectSettings, QleverStats, CreateProjectOptions, SyncOptions, SyncResult, SyncPreview, ScanOutputRecord, UnitCreditMap, UnitsConsumedDto, OrgCreditsDto, OrgPlanSummary, MonthlyConsumptionDto, ProjectConsumptionReportDto, OrgConsumptionReportDto, FileTypeConsumptionDto, FileTypeBreakdownDto, RouteTrafficDto, DayTrafficDto, MonthTrafficDto, TrafficReportDto, ViewUsageDto, DayUsageDto, MonthUsageDto, UsageReportDto, OrganizationData, OrgMember, ProfileSSOAccount, APIKeyInfo, APIKeyDoc, ProjectDoc, OrganizationDoc, UserDoc, UserSettings, CustomAppRecord, CustomAppWithHtml, CreateCustomAppOptions, UpdateCustomAppOptions, RDFWritingDoc, ProcessingStatus, ProcessingStage, DocumentProcessingStage, DocumentProgress, ProjectProcessingSummary, MyProcessingStatus, DocumentReprocessJob, ReprocessJobStatus, ViewDefinition, QueryCache, LangMap, CategoryDef, RelationshipDef, EntityCoreData, EntityRelationship, EntityRelationships, MapGeometry, EntityDetailedData, ProjectEntitiesData, SummaryGraphData, DocumentInfo, DocumentSummary, ProjectDocumentsData, } from './lib/models';
39
+ export type { CueSdkConfig, SsoProvider, PasswordCredentials, SearchRequest, SearchResponse, SearchSource, SearchOptions, ProjectData, ProjectSettings, QleverStats, CreateProjectOptions, SyncOptions, SyncResult, SyncPreview, ScanOutputRecord, UnitCreditMap, UnitsConsumedDto, OrgCreditsDto, OrgPlanSummary, MonthlyConsumptionDto, ProjectConsumptionReportDto, OrgConsumptionReportDto, FileTypeConsumptionDto, FileTypeBreakdownDto, RouteTrafficDto, DayTrafficDto, MonthTrafficDto, TrafficReportDto, ViewUsageDto, DayUsageDto, MonthUsageDto, UsageReportDto, OrganizationData, OrgMember, ProfileSSOAccount, APIKeyInfo, APIKeyDoc, ProjectDoc, OrganizationDoc, UserDoc, UserSettings, CustomAppRecord, CustomAppWithHtml, CreateCustomAppOptions, UpdateCustomAppOptions, RDFWritingDoc, ProcessingStatus, ProcessingStage, DocumentProcessingStage, DocumentProgress, ProjectProcessingSummary, MyProcessingStatus, DocumentReprocessJob, ReprocessJobStatus, ViewDefinition, QueryCache, LangMap, CategoryDef, RelationshipDef, EntityCoreData, EntityRelationship, EntityRelationships, MapGeometry, EntityDetailedData, ProjectEntitiesData, SummaryGraphData, PrototypeCategoryCount, PrototypeSummary, PrototypeProperty, PrototypeInstance, EntityAtExpressId, EntityModelLocation, ModelExpressIds, PrototypeCategoryExpressIds, DocumentInfo, DocumentSummary, ProjectDocumentsData, } from './lib/models';
38
40
  export type { AuthStateListener, Unsubscribe } from './lib/auth';
39
41
  export { CueTables } from './lib/tables';
40
42
  export type { ProjectTable } from './lib/tables';
41
43
  export { CueExtraction } from './lib/extraction';
42
44
  export type { ExtractionRequest, ExtractionResponse } from './lib/extraction';
43
45
  export { CueLlmTools } from './lib/llm-tools';
44
- export type { GenerateWranglingSchemaRequest, GenerateWranglingSchemaResponse, ExistingCategoryForSuggestion, SuggestEntityCategoryRequest, SuggestEntityCategoryResponse, SuggestEntityCategoryMatch, SuggestEntityCategorySuggestion, ColumnToSuggest, ColumnCategorySuggestionResult, SuggestEntityCategoryBatchRequest, SuggestEntityCategoryBatchResponse, } from './lib/llm-tools';
46
+ export type { GenerateWranglingSchemaRequest, GenerateWranglingSchemaResponse, ExistingCategoryForSuggestion, SuggestEntityCategoryRequest, SuggestEntityCategoryResponse, SuggestEntityCategoryMatch, SuggestEntityCategorySuggestion, ColumnToSuggest, ColumnCategorySuggestionResult, SuggestEntityCategoryBatchRequest, SuggestEntityCategoryBatchResponse, ColumnCounts, ColumnCategoryDecision, SuggestFromColumnsRequest, SuggestFromColumnsResponse, } from './lib/llm-tools';
45
47
  export { CueDataSources } from './lib/data-sources';
46
48
  export type { DataSourceRecord, XToRdfConfig, RmlXToRdfConfig, GraphXToRdfConfig, TypeMappingConfiguration, UploadDataSourceMode, UploadDataSourceResult, } from './lib/data-sources';
47
49
  export { CueGisSources } from './lib/gis-sources';
48
50
  export type { GisSourceRecord, GisSourceUploadFormat, GisSourceCrs } from './lib/gis-sources';
49
51
  export { CueSemanticTemplate } from './lib/semantic-template';
50
- export type { MutationResult as SemanticTemplateMutationResult, BatchMutationResult as SemanticTemplateBatchMutationResult, ContentCategoryInput, EntityCategoryInput, EntityRelationshipInput, } from './lib/semantic-template';
52
+ export type { MutationResult as SemanticTemplateMutationResult, BatchMutationResult as SemanticTemplateBatchMutationResult, ContentCategoryInput, EntityCategoryInput, EntityRelationshipInput, SchemaSource, } from './lib/semantic-template';
53
+ export { CueSchemaSuggestion } from './lib/schema-suggestion';
54
+ export { ENDPOINT_SCHEMA_SUGGESTION_FROM_PROSE, ENDPOINT_SCHEMA_SUGGESTION_CATALOGS, } from './lib/schema-suggestion';
55
+ export type { SuggestSchemaFromProseRequest, SuggestSchemaFromProseResponse, SchemaSuggestionUsage, } from './lib/schema-suggestion';
56
+ export * from './lib/project-schema';
51
57
  export { CueContexts } from './lib/contexts';
52
58
  export type { ContextDoc, ContextItem, McpContext } from './lib/models';
53
59
  export { CueAppData } from './lib/app-data';
package/index.js CHANGED
@@ -1,42 +1,62 @@
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-C9Og2u8R.js";
1
+ import { B as C, C as u, a as i, b as r, c as o, d as t, e as S, f as n, g as c, h as E, i as m, j as p, k as A, l, m as P, n as R, o as _, p as I, q as d, r as g, s as T, t as D, u as O, v as N, w as U, x as G, y as h, z as f, A as j, D as v, E as x, F as M, G as y, H as B, I as F, J as L, K as H, L as b, M as K, N as q, O as w, P as Q, Q as V, R as W, S as X, T as Y, U as k, V as z, W as J, X as Z, Y as $, Z as ee, _ as ae, $ as se, a0 as Ce, a1 as ue, a2 as ie, a3 as re } from "./document-filter-CBrY09DH.js";
2
+ import "uuid";
2
3
  export {
3
- a as BASE_CURRENCY,
4
- u as Cue,
5
- C as CueAdmin,
6
- t as CueApi,
7
- i as CueAppData,
8
- r as CueApps,
9
- o as CueAuth,
10
- c as CueCache,
11
- n as CueContexts,
12
- p as CueCurrency,
13
- S as CueDataSources,
14
- m as CueDmsApi,
15
- E as CueDocumentFilter,
16
- A as CueExtraction,
17
- P as CueGis,
18
- R as CueGisSources,
19
- l as CueIndexApi,
20
- g as CueLlmTools,
4
+ C as BASE_CURRENCY,
5
+ u as CORE_PREFIXES,
6
+ i as CanonicalPolicy,
7
+ r as CatalogKind,
8
+ o as Cue,
9
+ t as CueAdmin,
10
+ S as CueApi,
11
+ n as CueAppData,
12
+ c as CueApps,
13
+ E as CueAuth,
14
+ m as CueCache,
15
+ p as CueContexts,
16
+ A as CueCurrency,
17
+ l as CueDataSources,
18
+ P as CueDmsApi,
19
+ R as CueDocumentFilter,
20
+ _ as CueExtraction,
21
+ I as CueGis,
22
+ d as CueGisSources,
23
+ g as CueIndexApi,
24
+ T as CueLlmTools,
21
25
  D as CueMcp,
22
- j as CuePrivileges,
23
- U as CueProcessingApi,
24
- x as CueProfile,
25
- d as CueProjectDocuments,
26
- f as CueProjectEntities,
27
- h as CueProjectSchema,
28
- I as CueProjectView,
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
26
+ O as CuePrivileges,
27
+ N as CueProcessingApi,
28
+ U as CueProfile,
29
+ G as CueProjectDocuments,
30
+ h as CueProjectEntities,
31
+ f as CueProjectSchema,
32
+ j as CueProjectView,
33
+ v as CueProjects,
34
+ x as CueRequestError,
35
+ M as CueSchemaSuggestion,
36
+ y as CueSemanticTemplate,
37
+ B as CueSignUp,
38
+ F as CueSignal,
39
+ L as CueStorage,
40
+ H as CueSyncApi,
41
+ b as CueTables,
42
+ K as CueUserSettings,
43
+ q as DEFAULT_SCHEMA_BASE,
44
+ w as ENDPOINT_SCHEMA_SUGGESTION_CATALOGS,
45
+ Q as ENDPOINT_SCHEMA_SUGGESTION_FROM_PROSE,
46
+ V as EmbeddingBasis,
47
+ W as NumeralRole,
48
+ X as Provenance,
49
+ Y as REQUIRED_ROLES,
50
+ k as ResolutionIdentity,
51
+ z as SUPPORTED_CURRENCIES,
52
+ J as SchemaTermKind,
53
+ Z as configureScanWasm,
54
+ $ as cueComputed,
55
+ ee as deriveIri,
56
+ ae as expandCurie,
57
+ se as isCurie,
58
+ Ce as rdfBase,
59
+ ue as resolveIri,
60
+ ie as resolveRef,
61
+ re as schemaGraphIri
42
62
  };
package/lib/api.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CueBlobStorage } from 'js-databases';
1
+ import { CueBlobStorage } from '../../databases/src/index';
2
2
  import { CueAuth } from './auth';
3
3
  import { SearchRequest, SearchResponse, ShaclValidationReport, UnitsConsumedDto } from './models';
4
4
  import { CueProjects } from './project';
@@ -16,7 +16,15 @@ import { CueDmsApi } from './dms';
16
16
  import { CueLlmTools } from './llm-tools';
17
17
  import { CueDataSources } from './data-sources';
18
18
  import { CueGisSources } from './gis-sources';
19
+ import { CueSchemaSuggestion } from './schema-suggestion';
19
20
  import { CueSemanticTemplate } from './semantic-template';
21
+ export interface PutAlternativeRepresentationResult {
22
+ success: boolean;
23
+ contentIRI: string;
24
+ remoteRelativePath: string;
25
+ suffix: string;
26
+ quads: number;
27
+ }
20
28
  export declare class CueApi {
21
29
  private readonly _auth;
22
30
  private readonly _gatewayUrl;
@@ -51,6 +59,8 @@ export declare class CueApi {
51
59
  /** Mutates a project's custom extraction/classification schema (content categories, entity
52
60
  * categories, entity relationships) and reloads its `databases-cue` schema graph. */
53
61
  readonly semanticTemplate: CueSemanticTemplate;
62
+ /** Prose into a proposed `ProjectSchema`, selected from the published term catalogues. */
63
+ readonly schemaSuggestion: CueSchemaSuggestion;
54
64
  /** Active language used for language-sensitive SPARQL queries across all project classes. */
55
65
  language: string;
56
66
  /** Updates the active language. All project classes (`CueProjectSchema`, `CueProjectDocuments`, `CueProjectEntities`) read this at query time. */
@@ -70,13 +80,20 @@ export declare class CueApi {
70
80
  * Execute a SPARQL query against the project's triplestore.
71
81
  * The user must be authenticated before calling this.
72
82
  *
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.
83
+ * `graphType` is accepted for call-site compatibility with callers that
84
+ * still thread a `'fuseki' | 'qlever'` value through from elsewhere in the
85
+ * SDK (see TODO.md), but it no longer changes anything here: qlever is the
86
+ * only graph backend left — legacy Fuseki's `/triplestore/*` Kong route is
87
+ * gone, so routing a `'fuseki'` value to it would just 404.
88
+ *
89
+ * `responseMime` picks the result format via the `Accept` header — e.g.
90
+ * `'application/sparql-results+json'` or `'text/csv'` for SELECT/ASK, or
91
+ * `'text/turtle'` / `'application/ld+json'` / `'application/n-triples'` for
92
+ * CONSTRUCT/DESCRIBE. Leave it unset to let the server pick the default for
93
+ * the query's form (SELECT/ASK → sparql-results+json, CONSTRUCT/DESCRIBE →
94
+ * n-triples).
78
95
  */
79
- sparql(query: string, projectId: string, graphType?: 'fuseki' | 'qlever'): Promise<unknown>;
96
+ sparql(query: string, projectId: string, graphType?: 'fuseki' | 'qlever', responseMime?: string): Promise<unknown>;
80
97
  /**
81
98
  * Validate a SHACL shape against the project's triplestore.
82
99
  *
@@ -90,7 +107,7 @@ export declare class CueApi {
90
107
  shacl(shape: string, projectId: string, options?: {
91
108
  format?: 'json-ld' | 'turtle';
92
109
  verbose?: boolean;
93
- graphType?: 'fuseki' | 'qlever';
110
+ graphType?: 'qlever';
94
111
  }): Promise<ShaclValidationReport | string>;
95
112
  /**
96
113
  * Per-extension credit rates for `tier` (e.g. `{ pdf: 4, ifc: 2, dwg: 2 }`),
@@ -100,4 +117,21 @@ export declare class CueApi {
100
117
  */
101
118
  getUnitCredits(tier: 's' | 'm' | 'l'): Promise<Record<string, number>>;
102
119
  getConsumption(projectId: string): Promise<UnitsConsumedDto>;
120
+ /**
121
+ * Attaches `file` to `documentUUID` as a `qcy:alternativeRepresentation` — the same mechanism
122
+ * `processors-bim`/`processors-cad` use internally (see `alternativeRepresentation()` in
123
+ * `js/rdf-document-writers`), exposed here for a client that already produced a derivation
124
+ * itself (e.g. the x-to-rdf tuner's client-side BIM parse producing a model-summary markdown).
125
+ *
126
+ * @param location - `'processed'` for a derivation of the source document (lands where a
127
+ * processor would have written it, e.g. `{projectId}/md/{documentUUID}.md`); `'raw'` for an
128
+ * alternative original companion file.
129
+ */
130
+ putAlternativeRepresentation(projectId: string, documentUUID: string, file: Blob, opts: {
131
+ location: 'raw' | 'processed';
132
+ suffix: string;
133
+ fileContentClasses?: string[];
134
+ processorId?: string;
135
+ comment?: string;
136
+ }): Promise<PutAlternativeRepresentationResult>;
103
137
  }
package/lib/auth.d.ts CHANGED
@@ -12,6 +12,7 @@ export declare class CueAuth {
12
12
  private readonly _isSuperAdminSignal;
13
13
  private readonly _userIdsSignal;
14
14
  private readonly _stopTokenListener;
15
+ private _ssoPending;
15
16
  /** Reactive auth state — emits the signed-in `User`, or `null` when signed out. */
16
17
  readonly user: ReadonlySignal<User | null>;
17
18
  /** Reactive Firebase ID token — refreshes automatically; `null` when signed out. */
@@ -21,6 +22,7 @@ export declare class CueAuth {
21
22
  /** All unique UIDs for the current user (Firebase UID + linked provider UIDs). */
22
23
  readonly userIds: ReadonlySignal<string[]>;
23
24
  constructor(app: FirebaseApp, useEmulator: boolean | undefined, endpoints: CueEndpoints);
25
+ private _publish;
24
26
  /** Stop all internal Firebase listeners. Call when the `Cue` instance is no longer needed. */
25
27
  destroy(): void;
26
28
  /** Sign in with Google or Microsoft via browser popup */
@@ -39,6 +41,13 @@ export declare class CueAuth {
39
41
  * Call this once on app startup before showing a sign-in UI.
40
42
  */
41
43
  checkRedirectResult(): Promise<User | null>;
44
+ /**
45
+ * SSO may sign in to an existing account but never create one. Firebase
46
+ * creates the account before we can object, so the backend checks it
47
+ * afterwards and deletes it if it is a fresh sign-up; we sign out and throw.
48
+ * Fails closed: if the check cannot be made, the session is dropped.
49
+ */
50
+ private _confirmSsoSignIn;
42
51
  /**
43
52
  * One-shot async check — returns `true` if the current user has the
44
53
  * `superadmin` custom claim. For reactive use, read `cue.auth.isSuperAdmin`
package/lib/cue.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { FirebaseApp } from 'firebase/app';
2
2
  import { FirebaseStorage } from 'firebase/storage';
3
- import { CueBlobStorage } from 'js-databases';
3
+ import { CueBlobStorage } from '../../databases/src/index';
4
4
  import { CueAuth } from './auth';
5
5
  import { CueSignUp } from './signup';
6
6
  import { CueStorage } from './storage';
@@ -1,9 +1,19 @@
1
- import { CueBlobStorage } from 'js-databases';
1
+ import { CueBlobStorage } from '../../databases/src/index';
2
2
  import { CueAuth } from './auth';
3
- export type XToRdfConfig = RmlXToRdfConfig | GraphXToRdfConfig | DecompositionConfig | SheetXToRdfConfig;
3
+ export type XToRdfConfig = RmlXToRdfConfig | GraphXToRdfConfig | DecompositionConfig | SheetXToRdfConfig | RegisterXToRdfConfig | BimXToRdfConfig | FilesXToRdfConfig | TextXToRdfConfig;
4
4
  interface XToRdfConfigBase {
5
5
  /** Steps run on the transform's output, in order — see `XToRdfPostProcessingStep`. */
6
6
  postProcessing?: XToRdfPostProcessingStep[];
7
+ /** The original source file(s) this mapping was built from, persisted via
8
+ * `DataSourceHandlers.uploadSourceFile` — lets the tuner wizard's "Edit mapping" fetch the
9
+ * exact file(s) back (`DataSourceHandlers.getSourceFile`) instead of asking the user to
10
+ * re-upload before it can resume. Sheet: one entry. Graph: one per loaded `.ttl`. BIM: one
11
+ * entry, alongside its own `sourceDocumentUUID` below (kept separate — that one is for the
12
+ * document viewer, this one is for wizard resume). */
13
+ sourceFiles?: {
14
+ documentUUID: string;
15
+ fileName: string;
16
+ }[];
7
17
  }
8
18
  export interface RmlXToRdfConfig extends XToRdfConfigBase {
9
19
  type: 'rml';
@@ -56,6 +66,119 @@ export interface SheetXToRdfConfig extends XToRdfConfigBase {
56
66
  type: 'sheet';
57
67
  mapping: SheetMappingConfiguration;
58
68
  }
69
+ /**
70
+ * A DMS export / document register: a table whose rows are files and whose every column is a fact
71
+ * the archive keeps about one — its document type, its status, its revision, who filed it.
72
+ *
73
+ * Its own kind rather than a `sheet` mapping with a special column role, because the two ask
74
+ * different questions of a table. The sheet route asks what things a table names and how they
75
+ * relate; a register names none, and mapping its columns as entity categories produced terms
76
+ * standing for nothing. Every column becomes a `qcy:Property` on the row's `qcy:FileLocation`, and
77
+ * what those properties mean is left to resolution, which can see every source at once.
78
+ */
79
+ export interface RegisterXToRdfConfig extends XToRdfConfigBase {
80
+ type: 'register';
81
+ mapping: RegisterMappingConfiguration;
82
+ }
83
+ /**
84
+ * The only config whose input is the project's **own** file locations rather than an upload: one
85
+ * regex per entity category, run over every `qcy:filePath`, linking each file to the canonical
86
+ * entity its filename encodes. A client numbering standard (`33-ARC-H10-…`) is exactly this.
87
+ *
88
+ * Having no uploaded file has two consequences. It is run with `refreshDataSource` rather than
89
+ * `uploadData`, so re-reading the project after new files arrive costs one call and no
90
+ * re-authoring. And it attaches to the `qcy:FileLocation` IRIs already in the graph, so unlike the
91
+ * sheet route it never re-derives one.
92
+ */
93
+ export interface FilesXToRdfConfig extends XToRdfConfigBase {
94
+ type: 'files';
95
+ mappings: FilePathMapping[];
96
+ /** Restricts which files are scanned, tested against `qcy:filePath`. Absent scans every file. */
97
+ pathFilter?: string;
98
+ }
99
+ /**
100
+ * The third source of the same facts: what the documents themselves say.
101
+ *
102
+ * Same `mappings` as `files`, pointed at text instead of paths, so one coding scheme produces all
103
+ * three sources without a pattern being re-authored. Run through `refreshDataSource` like `files`,
104
+ * for the same reason — its input is the project's own documents, not an upload.
105
+ *
106
+ * The matching happens in `enrichers-regex-matcher` and yields `qcy:EntityMention`s, so this is the
107
+ * one kind with a resolution step: a mention whose value is in the mapping's declared list is
108
+ * linked to that canonical, and the file the text belongs to gets the same `qcy:about` edge the
109
+ * other two sources emit — which is what makes the three comparable.
110
+ */
111
+ export interface TextXToRdfConfig extends XToRdfConfigBase {
112
+ type: 'text';
113
+ mappings: FilePathMapping[];
114
+ /** Search each document's `qcy:textSummary`. Defaults to true — one short string per document,
115
+ * and the one that names a project's subjects. */
116
+ searchSummary?: boolean;
117
+ /** Search each document's full extracted text. Defaults to false: orders of magnitude more text,
118
+ * read from blob storage rather than the graph. */
119
+ searchTextRaw?: boolean;
120
+ /** Which extracted-text files body-text search reads, as a regex over their path. Absent means
121
+ * the matcher's default (markdown). Only meaningful with `searchTextRaw`. */
122
+ filePathFilter?: string;
123
+ /** Caps how many documents are scanned, for trying a scheme out first. Absent scans every one. */
124
+ limit?: number;
125
+ }
126
+ export interface FilePathMapping {
127
+ categoryIri: string;
128
+ /**
129
+ * Unanchored, with exactly **one** capture group — the group is the field being read, and the
130
+ * surrounding segments are what stop a stray match elsewhere in the path. Derived by cue-ui's
131
+ * `codingSchemeToRegex` rather than hand-authored, which is what guarantees both properties and
132
+ * keeps the pattern valid under RE2 for `regex-matcher` to reuse.
133
+ */
134
+ regex: string;
135
+ /** Captured code (lower-cased) -> the IRI of the canonical entity already declared for it. */
136
+ iriByValue?: Record<string, string>;
137
+ /** What to do with a captured code the value list does not have. `'skip'` (the default) records
138
+ * nothing — a filename carrying an undeclared code is a finding to show, not a term to invent. */
139
+ unmatched?: 'skip' | 'mint';
140
+ }
141
+ /**
142
+ * A BIM model uploaded through the x-to-rdf tuner's client-side IFC parser. Unlike `graph`, there
143
+ * is no `constructQuery` to run server-side — the parser's own output already IS the canonical
144
+ * QCY graph (stable IRIs derived from IFC GUIDs), so the backend transform is a passthrough that
145
+ * mints nothing. `sourceDocumentUUID`/`markdownRemoteRelativePath` are what the document viewer
146
+ * needs later to render the 3D model + markdown summary alongside this data source's own named
147
+ * graph — see `CueApi.putAlternativeRepresentation` for how the markdown gets attached.
148
+ */
149
+ export interface BimXToRdfConfig extends XToRdfConfigBase {
150
+ type: 'bim';
151
+ /** The parser knobs the model was parsed with. Not interpreted by the SDK itself, same
152
+ * "opaque but structurally mirrored" role `wizardConfig` plays for `graph` configs. */
153
+ parseSettings?: IfcParseSettings;
154
+ /** The original `.ifc`, persisted via `CueSyncApi.syncBrowserFile` with `skipProcessing: true`. */
155
+ sourceDocumentUUID?: string;
156
+ /** The parser's model-summary markdown, attached to `sourceDocumentUUID` as a
157
+ * `qcy:alternativeRepresentation` at `{projectId}/md/{sourceDocumentUUID}.md`. */
158
+ markdownRemoteRelativePath?: string;
159
+ }
160
+ /** Mirrors cue-ui's tuner-x-to-rdf `IfcParseSettings`. The two prototype fields are optional
161
+ * here because data sources saved before they existed carry a `parseSettings` without them;
162
+ * cue-ui's panel, which always writes a full object, has them required. */
163
+ export interface IfcParseSettings {
164
+ enabledParsers: {
165
+ bot: boolean;
166
+ products: boolean;
167
+ properties: boolean;
168
+ selectors: boolean;
169
+ polygons: boolean;
170
+ };
171
+ buildSummary: boolean;
172
+ buildDescriptions: boolean;
173
+ excludedPSets: string[];
174
+ /** Writes each IFC type object (family type) as a `qcy:EntityPrototype` its occurrences point
175
+ * at with `qcy:inheritsFrom`. Absent on data sources saved before prototypes existed, which
176
+ * the parser reads as on. */
177
+ useEntityPrototypes?: boolean;
178
+ /** Only meaningful with `useEntityPrototypes`. Also moves properties the IFC left on the
179
+ * occurrences up onto the prototype when every occurrence of the type shares the value. */
180
+ hoistSharedProperties?: boolean;
181
+ }
59
182
  /**
60
183
  * How a spreadsheet's columns become RDF: every column is either ignored, an entity — minted
61
184
  * onto the same deterministic-IRI scheme `graph`/`decomposition` use
@@ -70,12 +193,88 @@ export interface SheetMappingConfiguration {
70
193
  columnRoles: Record<string, SheetColumnRole>;
71
194
  relationMappings: SheetRelationMapping[];
72
195
  fileLinkage?: SheetFileLinkage | null;
196
+ /** Cleaning rules run on every row before mapping, in order. Not opaque to the backend —
197
+ * the sheet transform executes these itself (see `apply-wrangling.ts` in
198
+ * `rdf-document-writers`), same reasoning as `columnRoles`/`relationMappings` above. */
199
+ wrangling?: WranglingSettings | null;
73
200
  }
201
+ /**
202
+ * How a document register becomes RDF — mirrors `RegisterMapping` in js/rdf-document-writers,
203
+ * which documents the triples each field produces. Not opaque to the backend: the register
204
+ * transform reads it directly.
205
+ */
206
+ export interface RegisterMappingConfiguration {
207
+ id?: string;
208
+ name: string;
209
+ /** The one column that is not a property: the file's path or name. */
210
+ filePathColumn: string;
211
+ /** How that cell finds the `qcy:FileLocation` the project already holds — see
212
+ * `SheetFileLinkage.pathMatch`, same meaning. */
213
+ pathMatch?: 'exact' | 'basename';
214
+ /** Column -> the `qcy:label` its values are written under. Explicit, so a register re-uploaded
215
+ * with an extra column does not start writing properties nobody named. */
216
+ propertyLabels: Record<string, string>;
217
+ /** Optional: the schema's regex-bearing entity categories (`qcy-t:regex`), read off the
218
+ * file-path cell — same shape and contract as the `files` kind's `FilePathMapping`. */
219
+ pathPatterns?: FilePathMapping[];
220
+ /** Cleaning rules run on every row before mapping, in order — same treatment `sheet` gives its
221
+ * own. */
222
+ wrangling?: WranglingSettings | null;
223
+ }
224
+ /** Mirrors cue-ui's `data-wrangling/models.ts` exactly — see that file for the reasoning behind
225
+ * each rule type. Kept in structural sync by hand, same convention as `IfcParseSettings` above. */
226
+ export type WranglingRuleType = 'splitCell' | 'formula' | 'setUndefined' | 'parseDate';
227
+ export interface WranglingRuleBase {
228
+ id: string;
229
+ type: WranglingRuleType;
230
+ /** Fields the rule applies to. A rule with no columns is a no-op. */
231
+ columns: string[];
232
+ disabled?: boolean;
233
+ }
234
+ export type SplitCellMode = 'expandRows' | 'first' | 'last' | 'join';
235
+ export interface SplitCellRule extends WranglingRuleBase {
236
+ type: 'splitCell';
237
+ separator: string;
238
+ regex?: boolean;
239
+ trim?: boolean;
240
+ dropEmpty?: boolean;
241
+ mode: SplitCellMode;
242
+ joinSeparator?: string;
243
+ }
244
+ export interface FormulaRule extends WranglingRuleBase {
245
+ type: 'formula';
246
+ expression: string;
247
+ }
248
+ export interface SetUndefinedRule extends WranglingRuleBase {
249
+ type: 'setUndefined';
250
+ values: string[];
251
+ caseInsensitive?: boolean;
252
+ }
253
+ export interface ParseDateRule extends WranglingRuleBase {
254
+ type: 'parseDate';
255
+ inputFormat?: string;
256
+ }
257
+ export type WranglingRule = SplitCellRule | FormulaRule | SetUndefinedRule | ParseDateRule;
258
+ export interface WranglingSettings {
259
+ rules: WranglingRule[];
260
+ }
261
+ /**
262
+ * `pattern` is an optional single-capture regex applied to a cell before lookup, so a cell that
263
+ * carries its code alongside its meaning (`05-Elektro`) resolves on the code alone.
264
+ *
265
+ * `iriByValue` maps the extracted string (lower-cased) to a canonical entity that already exists —
266
+ * a value declared in the project schema. On a hit the entity is not minted at all: only the
267
+ * `qcy:about` edge is written, so the schema graph keeps sole ownership of its value, notation and
268
+ * labels, and a fact read from a spreadsheet and the same fact read from a filename land on one
269
+ * entity instead of two. On a miss the cell mints as it always has.
270
+ */
74
271
  export type SheetColumnRole = {
75
272
  kind: 'unmapped';
76
273
  } | {
77
274
  kind: 'entity';
78
275
  categoryIri: string;
276
+ pattern?: string;
277
+ iriByValue?: Record<string, string>;
79
278
  } | {
80
279
  kind: 'attribute';
81
280
  entityColumn: string;
@@ -92,6 +291,16 @@ export interface SheetRelationMapping {
92
291
  export interface SheetFileLinkage {
93
292
  filePathColumn: string;
94
293
  md5Column?: string;
294
+ /**
295
+ * How the path cell finds its `qcy:FileLocation`. `'exact'` (the default) matches `qcy:filePath`
296
+ * verbatim; `'basename'` also accepts a cell holding only the file's name — the shape a DMS
297
+ * export uses — and refuses a name two files share rather than picking one.
298
+ *
299
+ * Either way the location IRI the graph already holds is what the row attaches to, instead of
300
+ * one re-derived from the cell. The derivation passes no provider id while ingestion passes the
301
+ * file's own, so a re-derived IRI misses every file that arrived through a connector.
302
+ */
303
+ pathMatch?: 'exact' | 'basename';
95
304
  }
96
305
  /**
97
306
  * A step applied to a transform's *output*, after the CONSTRUCT query (or RML mapping) has run.
@@ -218,6 +427,18 @@ export declare class CueDataSources {
218
427
  * before the handler even runs, is still thrown from `response.ok` as before).
219
428
  */
220
429
  uploadData(projectId: string, id: string, files: Blob[], mode: UploadDataSourceMode, onProgress?: (event: DataSourceProgressEvent) => void): Promise<UploadDataSourceResult>;
430
+ /**
431
+ * Re-runs a data source that has no uploaded input — today only a `files` config, whose input is
432
+ * the project's own file locations. This is how "new files have arrived since this ran" is
433
+ * answered: one call, no re-authoring and nothing to re-upload.
434
+ *
435
+ * Always replaces, because re-reading the same input is a recomputation rather than an addition.
436
+ * Same NDJSON progress stream and same `{added, removed}` result as `uploadData`, so a caller
437
+ * that already handles an upload handles this with no new branch. Every other config type is
438
+ * refused — a sheet or RML source has no input without its file, and re-running one with none
439
+ * would quietly empty its graph.
440
+ */
441
+ refreshDataSource(projectId: string, id: string, onProgress?: (event: DataSourceProgressEvent) => void): Promise<UploadDataSourceResult>;
221
442
  /**
222
443
  * Dry-run: runs `config` against `files` and returns the resulting Turtle,
223
444
  * without creating a data source or writing anything to the graph/ledger —
@@ -1,6 +1,6 @@
1
1
  import { CueApi } from './api';
2
2
  import { ReadonlySignal } from './signal';
3
- import { FileType } from 'js/models';
3
+ import { FileType } from '../../models/src/index';
4
4
  import { DocumentInfo, ProjectDocumentsData } from './models';
5
5
  /**
6
6
  * Manages document data for a single project.