@qaecy/cue-sdk 0.0.26 → 0.0.28

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/README.md CHANGED
@@ -94,6 +94,37 @@ Sign in using a Cue API key. Intended for non-interactive/server-side use (e.g.
94
94
  const user = await cue.auth.signInWithApiKey('MY_CUE_API_KEY', 'my-project-id');
95
95
  ```
96
96
 
97
+ ### `cue.auth.signInWithCustomToken(token)`
98
+
99
+ Sign in using a Firebase custom token. Intended for server-issued auth flows such as MCP tools or OAuth-protected backends where the server mints a token on behalf of the user.
100
+
101
+ **Typical flow (e.g. MCP + Google OAuth):**
102
+
103
+ 1. The server receives a Google OAuth access token (e.g. via the MCP host's OAuth dance).
104
+ 2. The server looks up the Firebase UID for the Google `sub` claim and mints a custom token using Firebase Admin:
105
+ ```typescript
106
+ // Server side (Node.js / Firebase Admin)
107
+ import * as admin from 'firebase-admin';
108
+
109
+ async function mintCustomToken(googleAccessToken: string): Promise<string> {
110
+ const res = await fetch('https://www.googleapis.com/oauth2/v3/userinfo', {
111
+ headers: { Authorization: `Bearer ${googleAccessToken}` },
112
+ });
113
+ const { sub } = await res.json(); // Google UID
114
+
115
+ const user = await admin.auth().getUserByProviderUid('google.com', sub);
116
+ return admin.auth().createCustomToken(user.uid);
117
+ }
118
+ ```
119
+ 3. The custom token is passed to the browser/view (e.g. via `structuredContent`).
120
+ 4. The client signs in instantly — no popup, no redirect, no polling:
121
+ ```typescript
122
+ // Browser / view side
123
+ const cue = new Cue();
124
+ await cue.auth.signInWithCustomToken(customToken);
125
+ // cue is now fully authenticated
126
+ ```
127
+
97
128
  ### `cue.auth.signOut()`
98
129
 
99
130
  ```typescript
@@ -203,6 +234,43 @@ const project = await cue.api.projects.createProject({
203
234
 
204
235
  Entity data for a project is accessed via a `CueProjectView`. Create a view with `cue.createProjectView(projectId)` and use `view.entities` (`CueProjectEntities`) for all entity-level operations.
205
236
 
237
+ ### `view.entities.entitiesByCategory(categoryIris, includeMetadata?)`
238
+
239
+ Fetch all canonical entities that belong to at least one of the given category IRIs. Accepts both full HTTP IRIs and prefixed forms.
240
+
241
+ By default returns only `{ iri, uuid }` — suitable for feeding directly into `requestEntityData()` for lazy detail loading. Pass `true` to also receive `value` and `categories`.
242
+
243
+ ```typescript
244
+ // Lean — just IRIs + UUIDs (default)
245
+ const entities = await view.entities.entitiesByCategory([
246
+ 'qcy:Building',
247
+ 'qcy:BuildingStorey',
248
+ ]);
249
+ const uuids = entities.map((e) => e.uuid);
250
+ view.entities.requestEntityData(uuids); // lazy-loads labels + categories
251
+
252
+ // With metadata
253
+ const entities = await view.entities.entitiesByCategory(
254
+ ['https://cue.qaecy.com/ontology#Building'],
255
+ true,
256
+ );
257
+ entities.forEach((e) => console.log(e.uuid, e.value, e.categories));
258
+ ```
259
+
260
+ | Parameter | Type | Description |
261
+ |---|---|---|
262
+ | `categoryIris` | `string[]` | Full IRIs (`https://…`) or prefixed forms (`qcy:…`) |
263
+ | `includeMetadata` | `boolean` | `false` (default) → `{ iri, uuid }[]`; `true` → adds `value` and `categories` |
264
+
265
+ ### `view.entities.contentCategoriesInProject(orderByOccurrences?)`
266
+
267
+ Fetch all `qcy:EntityCategory` IRIs present in this project with their preferred labels:
268
+
269
+ ```typescript
270
+ const cats = await view.entities.contentCategoriesInProject();
271
+ cats.forEach((c) => console.log(c.iri, c.label));
272
+ ```
273
+
206
274
  ### `view.entities.buildSummaryGraph(format?)`
207
275
 
208
276
  Fetches a project-level summary of entity category relationships: how many times entities of one category point to entities of another via each predicate, ordered by descending occurrence count.
@@ -227,6 +295,68 @@ const md = await view.entities.buildSummaryGraph('md');
227
295
  const raw = await view.entities.buildSummaryGraph();
228
296
  ```
229
297
 
298
+ ## Documents
299
+
300
+ Document data for a project is accessed via `view.documents` (`CueProjectDocuments`). Use `fetchOverview()` to get aggregate counts and the methods below to retrieve document lists.
301
+
302
+ ### `view.documents.documentsBySuffix(suffixes, includeMetadata?)`
303
+
304
+ Fetch all documents whose file extension matches one of the given suffixes. The leading dot is optional — both `'ifc'` and `'.ifc'` are accepted.
305
+
306
+ By default returns only `{ iri, uuid }` for pairing with `requestDocumentData()`. Pass `true` to also receive `path`, `suffix`, and `size`.
307
+
308
+ ```typescript
309
+ // Lean — just IRIs + UUIDs (default)
310
+ const docs = await view.documents.documentsBySuffix(['.ifc', '.rvt']);
311
+ view.documents.requestDocumentData(docs.map((d) => d.uuid));
312
+
313
+ // With file metadata
314
+ const docs = await view.documents.documentsBySuffix(['pdf', 'docx'], true);
315
+ docs.forEach((d) => console.log(d.path, d.suffix, d.size));
316
+ ```
317
+
318
+ ### `view.documents.documentsByFileType(fileTypes, includeMetadata?)`
319
+
320
+ Fetch documents by semantic `FileType` category. Resolves all matching suffixes automatically from the built-in `fileExtensionsInfo` map.
321
+
322
+ ```typescript
323
+ import { FileType } from 'js/models';
324
+
325
+ // All BIM and CAD files
326
+ const docs = await view.documents.documentsByFileType([
327
+ FileType.BIM,
328
+ FileType.CAD,
329
+ ]);
330
+
331
+ // With metadata
332
+ const docs = await view.documents.documentsByFileType([FileType.IMAGE], true);
333
+ ```
334
+
335
+ ### `view.documents.documentsByMime(mimeTypes, includeMetadata?)`
336
+
337
+ Fetch documents whose MIME type matches one of the given strings:
338
+
339
+ ```typescript
340
+ const docs = await view.documents.documentsByMime([
341
+ 'application/x-step', // .ifc
342
+ 'application/pdf',
343
+ ]);
344
+
345
+ // With metadata
346
+ const docs = await view.documents.documentsByMime(
347
+ ['image/png', 'image/jpeg'],
348
+ true,
349
+ );
350
+ ```
351
+
352
+ | Method | Filters by | Extra metadata (`true`) |
353
+ |---|---|---|
354
+ | `documentsBySuffix` | File extension string(s) | `path`, `suffix`, `size` |
355
+ | `documentsByFileType` | `FileType` enum value(s) | `path`, `suffix`, `size` |
356
+ | `documentsByMime` | MIME type string(s) | `path`, `suffix`, `size` |
357
+
358
+ All three exclude alternative representations (e.g. derived `.fragments` tiles) from results.
359
+
230
360
  ## Node.js — file sync
231
361
 
232
362
  For server-side or CLI use with file-sync capabilities, import from `@qaecy/cue-sdk/node`: