@robosystems/client 0.2.13 → 0.2.15

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/sdk/sdk.gen.js CHANGED
@@ -2,8 +2,8 @@
2
2
  // This file is auto-generated by @hey-api/openapi-ts
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.batchProcessQueries = exports.executeSpecificAgent = exports.getAgentMetadata = exports.autoSelectAgent = exports.listAgents = exports.syncConnection = exports.getConnection = exports.deleteConnection = exports.oauthCallback = exports.initOAuth = exports.createLinkToken = exports.exchangeLinkToken = exports.getConnectionOptions = exports.createConnection = exports.listConnections = exports.getOrgUsage = exports.getOrgLimits = exports.updateOrgMemberRole = exports.removeOrgMember = exports.inviteOrgMember = exports.listOrgMembers = exports.listOrgGraphs = exports.updateOrg = exports.getOrg = exports.createOrg = exports.listUserOrgs = exports.updateUserApiKey = exports.revokeUserApiKey = exports.createUserApiKey = exports.listUserApiKeys = exports.updateUserPassword = exports.updateUser = exports.getCurrentUser = exports.getServiceStatus = exports.getCaptchaConfig = exports.completeSsoAuth = exports.ssoTokenExchange = exports.generateSsoToken = exports.resetPassword = exports.validateResetToken = exports.forgotPassword = exports.checkPasswordStrength = exports.getPasswordPolicy = exports.verifyEmail = exports.resendVerificationEmail = exports.refreshAuthSession = exports.getCurrentAuthUser = exports.logoutUser = exports.loginUser = exports.registerUser = void 0;
5
- exports.listOrgSubscriptions = exports.createPortalSession = exports.getOrgBillingCustomer = exports.cancelOperation = exports.getOperationStatus = exports.streamOperationEvents = exports.getServiceOfferings = exports.selectGraph = exports.getAvailableGraphTiers = exports.getAvailableExtensions = exports.createGraph = exports.getGraphs = exports.queryTables = exports.ingestTables = exports.updateFileStatus = exports.getFileInfo = exports.deleteFile = exports.getUploadUrl = exports.listTableFiles = exports.listTables = exports.upgradeSubscription = exports.createRepositorySubscription = exports.getGraphSubscription = exports.getSubgraphQuota = exports.getSubgraphInfo = exports.deleteSubgraph = exports.createSubgraph = exports.listSubgraphs = exports.getGraphLimits = exports.getDatabaseInfo = exports.getDatabaseHealth = exports.checkStorageLimits = exports.getStorageUsage = exports.checkCreditBalance = exports.listCreditTransactions = exports.getCreditSummary = exports.validateSchema = exports.exportGraphSchema = exports.getGraphSchema = exports.executeCypherQuery = exports.getGraphUsageAnalytics = exports.getGraphMetrics = exports.getBackupStats = exports.restoreBackup = exports.getBackupDownloadUrl = exports.createBackup = exports.listBackups = exports.callMcpTool = exports.listMcpTools = exports.recommendAgent = void 0;
6
- exports.getCheckoutStatus = exports.createCheckoutSession = exports.getOrgUpcomingInvoice = exports.listOrgInvoices = exports.cancelOrgSubscription = exports.getOrgSubscription = void 0;
5
+ exports.cancelOperation = exports.getOperationStatus = exports.streamOperationEvents = exports.getServiceOfferings = exports.selectGraph = exports.getAvailableGraphTiers = exports.getAvailableExtensions = exports.createGraph = exports.getGraphs = exports.updateFile = exports.getFile = exports.deleteFile = exports.createFileUpload = exports.listFiles = exports.materializeGraph = exports.getMaterializationStatus = exports.saveView = exports.createView = exports.queryTables = exports.listTables = exports.upgradeSubscription = exports.createRepositorySubscription = exports.getGraphSubscription = exports.getSubgraphQuota = exports.getSubgraphInfo = exports.deleteSubgraph = exports.createSubgraph = exports.listSubgraphs = exports.getGraphLimits = exports.getDatabaseInfo = exports.getDatabaseHealth = exports.checkStorageLimits = exports.getStorageUsage = exports.checkCreditBalance = exports.listCreditTransactions = exports.getCreditSummary = exports.validateSchema = exports.exportGraphSchema = exports.getGraphSchema = exports.executeCypherQuery = exports.getGraphUsageAnalytics = exports.getGraphMetrics = exports.getBackupStats = exports.restoreBackup = exports.getBackupDownloadUrl = exports.createBackup = exports.listBackups = exports.callMcpTool = exports.listMcpTools = exports.recommendAgent = void 0;
6
+ exports.getCheckoutStatus = exports.createCheckoutSession = exports.getOrgUpcomingInvoice = exports.listOrgInvoices = exports.cancelOrgSubscription = exports.getOrgSubscription = exports.listOrgSubscriptions = exports.createPortalSession = exports.getOrgBillingCustomer = void 0;
7
7
  const client_gen_1 = require("./client.gen");
8
8
  /**
9
9
  * Register New User
@@ -1103,6 +1103,13 @@ exports.listAgents = listAgents;
1103
1103
  * - Leverage conversation history for contextual understanding
1104
1104
  * - Enable RAG for knowledge base enrichment
1105
1105
  *
1106
+ * **Subgraph Support:**
1107
+ * This endpoint accepts both parent graph IDs and subgraph IDs.
1108
+ * - Parent graph: Use `graph_id` like `kg0123456789abcdef`
1109
+ * - Subgraph: Use full subgraph ID like `kg0123456789abcdef_dev`
1110
+ * Agents operate on the specified graph/subgraph's data independently. RAG enrichment
1111
+ * and knowledge base search are scoped to the specific graph/subgraph.
1112
+ *
1106
1113
  * See request/response examples in the "Examples" dropdown below.
1107
1114
  */
1108
1115
  const autoSelectAgent = (options) => {
@@ -1287,6 +1294,13 @@ exports.recommendAgent = recommendAgent;
1287
1294
  * - User permissions and subscription tier
1288
1295
  * - Backend capabilities (Kuzu, Neo4j, etc.)
1289
1296
  *
1297
+ * **Subgraph Support:**
1298
+ * This endpoint accepts both parent graph IDs and subgraph IDs.
1299
+ * - Parent graph: Use `graph_id` like `kg0123456789abcdef`
1300
+ * - Subgraph: Use full subgraph ID like `kg0123456789abcdef_dev`
1301
+ * The returned tool list is identical for parent graphs and subgraphs, as all
1302
+ * MCP tools work uniformly across graph boundaries.
1303
+ *
1290
1304
  * **Note:**
1291
1305
  * MCP tool listing is included - no credit consumption required.
1292
1306
  */
@@ -1341,6 +1355,13 @@ exports.listMcpTools = listMcpTools;
1341
1355
  * - `408 Request Timeout`: Tool execution exceeded timeout
1342
1356
  * - Clients should implement exponential backoff on errors
1343
1357
  *
1358
+ * **Subgraph Support:**
1359
+ * This endpoint accepts both parent graph IDs and subgraph IDs.
1360
+ * - Parent graph: Use `graph_id` like `kg0123456789abcdef`
1361
+ * - Subgraph: Use full subgraph ID like `kg0123456789abcdef_dev`
1362
+ * MCP tools operate on the specified graph/subgraph independently. Each subgraph
1363
+ * has its own schema, data, and can be queried separately via MCP.
1364
+ *
1344
1365
  * **Credit Model:**
1345
1366
  * MCP tool execution is included - no credit consumption required. Database
1346
1367
  * operations (queries, schema inspection, analytics) are completely free.
@@ -1691,11 +1712,14 @@ const getGraphUsageAnalytics = (options) => {
1691
1712
  };
1692
1713
  exports.getGraphUsageAnalytics = getGraphUsageAnalytics;
1693
1714
  /**
1694
- * Execute Cypher Query (Read-Only)
1695
- * Execute a read-only Cypher query with intelligent response optimization.
1715
+ * Execute Cypher Query
1716
+ * Execute a Cypher query with intelligent response optimization.
1696
1717
  *
1697
- * **IMPORTANT: This endpoint is READ-ONLY.** Write operations (CREATE, MERGE, SET, DELETE) are not allowed.
1698
- * To load data into your graph, use the staging pipeline:
1718
+ * **IMPORTANT: Write operations depend on graph type:**
1719
+ * - **Main Graphs**: READ-ONLY. Write operations (CREATE, MERGE, SET, DELETE) are not allowed.
1720
+ * - **Subgraphs**: WRITE-ENABLED. Full Cypher write operations are supported for development and report creation.
1721
+ *
1722
+ * To load data into main graphs, use the staging pipeline:
1699
1723
  * 1. Create file upload: `POST /v1/graphs/{graph_id}/tables/{table_name}/files`
1700
1724
  * 2. Ingest to graph: `POST /v1/graphs/{graph_id}/tables/ingest`
1701
1725
  *
@@ -1748,6 +1772,12 @@ exports.getGraphUsageAnalytics = getGraphUsageAnalytics;
1748
1772
  * - `503 Service Unavailable`: Circuit breaker open or SSE disabled
1749
1773
  * - Clients should implement exponential backoff
1750
1774
  *
1775
+ * **Subgraph Support:**
1776
+ * This endpoint accepts both parent graph IDs and subgraph IDs.
1777
+ * - Parent graph: Use `graph_id` like `kg0123456789abcdef`
1778
+ * - Subgraph: Use full subgraph ID like `kg0123456789abcdef_dev`
1779
+ * Subgraphs share the same instance as their parent graph and have independent data.
1780
+ *
1751
1781
  * **Note:**
1752
1782
  * Query operations are included - no credit consumption required.
1753
1783
  * Queue position is based on subscription tier for priority.
@@ -1810,6 +1840,14 @@ exports.executeCypherQuery = executeCypherQuery;
1810
1840
  * Property discovery is limited to 10 properties per node type for performance.
1811
1841
  * For complete schema definitions, use `/schema/export`.
1812
1842
  *
1843
+ * ## Subgraph Support
1844
+ *
1845
+ * This endpoint accepts both parent graph IDs and subgraph IDs.
1846
+ * - Parent graph: Use `graph_id` like `kg0123456789abcdef`
1847
+ * - Subgraph: Use full subgraph ID like `kg0123456789abcdef_dev`
1848
+ * Each subgraph has independent schema and data. The returned schema reflects
1849
+ * only the specified graph/subgraph's actual structure.
1850
+ *
1813
1851
  * This operation is included - no credit consumption required.
1814
1852
  */
1815
1853
  const getGraphSchema = (options) => {
@@ -1919,6 +1957,13 @@ exports.exportGraphSchema = exportGraphSchema;
1919
1957
  * - Performance problems
1920
1958
  * - Naming conflicts
1921
1959
  *
1960
+ * **Subgraph Support:**
1961
+ * This endpoint accepts both parent graph IDs and subgraph IDs.
1962
+ * - Parent graph: Use `graph_id` like `kg0123456789abcdef`
1963
+ * - Subgraph: Use full subgraph ID like `kg0123456789abcdef_dev`
1964
+ * Schema validation is performed against the specified graph/subgraph's current
1965
+ * schema and data structure.
1966
+ *
1922
1967
  * This operation is included - no credit consumption required.
1923
1968
  */
1924
1969
  const validateSchema = (options) => {
@@ -2115,6 +2160,13 @@ exports.checkStorageLimits = checkStorageLimits;
2115
2160
  * - **Resource Usage**: Memory and storage consumption
2116
2161
  * - **Alerts**: Active warnings or issues
2117
2162
  *
2163
+ * **Subgraph Support:**
2164
+ * This endpoint accepts both parent graph IDs and subgraph IDs.
2165
+ * - Parent graph: Use `graph_id` like `kg0123456789abcdef`
2166
+ * - Subgraph: Use full subgraph ID like `kg0123456789abcdef_dev`
2167
+ * Health metrics are specific to the requested graph/subgraph. Subgraphs share the
2168
+ * same physical instance as their parent but have independent health indicators.
2169
+ *
2118
2170
  * This endpoint provides essential monitoring data for operational visibility.
2119
2171
  */
2120
2172
  const getDatabaseHealth = (options) => {
@@ -2153,6 +2205,13 @@ exports.getDatabaseHealth = getDatabaseHealth;
2153
2205
  * - **Backup Status**: Backup availability and recency
2154
2206
  * - **Timestamps**: Creation and modification dates
2155
2207
  *
2208
+ * **Subgraph Support:**
2209
+ * This endpoint accepts both parent graph IDs and subgraph IDs.
2210
+ * - Parent graph: Use `graph_id` like `kg0123456789abcdef`
2211
+ * - Subgraph: Use full subgraph ID like `kg0123456789abcdef_dev`
2212
+ * Returned metrics are specific to the requested graph/subgraph. Subgraphs have
2213
+ * independent size, node/relationship counts, and backup status.
2214
+ *
2156
2215
  * This endpoint provides essential database information for capacity planning and monitoring.
2157
2216
  */
2158
2217
  const getDatabaseInfo = (options) => {
@@ -2186,7 +2245,7 @@ exports.getDatabaseInfo = getDatabaseInfo;
2186
2245
  *
2187
2246
  * This unified endpoint provides all limits in one place for easier client integration.
2188
2247
  *
2189
- * **Note**: Limits vary based on subscription tier (Standard, Enterprise, Premium).
2248
+ * **Note**: Limits vary based on subscription tier (kuzu-standard, kuzu-large, kuzu-xlarge).
2190
2249
  */
2191
2250
  const getGraphLimits = (options) => {
2192
2251
  return (options.client ?? client_gen_1.client).get({
@@ -2237,7 +2296,7 @@ const listSubgraphs = (options) => {
2237
2296
  exports.listSubgraphs = listSubgraphs;
2238
2297
  /**
2239
2298
  * Create Subgraph
2240
- * Create a new subgraph within a parent graph.
2299
+ * Create a new subgraph within a parent graph, with optional data forking.
2241
2300
  *
2242
2301
  * **Requirements:**
2243
2302
  * - Valid authentication
@@ -2247,8 +2306,23 @@ exports.listSubgraphs = listSubgraphs;
2247
2306
  * - Must be within subgraph quota limits
2248
2307
  * - Subgraph name must be unique within the parent graph
2249
2308
  *
2309
+ * **Fork Mode:**
2310
+ * When `fork_parent=true`, the operation:
2311
+ * - Returns immediately with an operation_id for SSE monitoring
2312
+ * - Copies data from parent graph to the new subgraph
2313
+ * - Supports selective forking via metadata.fork_options
2314
+ * - Tracks progress in real-time via SSE
2315
+ *
2250
2316
  * **Returns:**
2251
- * - Created subgraph details including its unique ID
2317
+ * - Without fork: Immediate SubgraphResponse with created subgraph details
2318
+ * - With fork: Operation response with SSE monitoring endpoint
2319
+ *
2320
+ * **Subgraph ID format:** `{parent_id}_{subgraph_name}` (e.g., kg1234567890abcdef_dev)
2321
+ *
2322
+ * **Usage:**
2323
+ * - Subgraphs share parent's credit pool
2324
+ * - Subgraph ID can be used in all standard `/v1/graphs/{graph_id}*` endpoints
2325
+ * - Permissions inherited from parent graph
2252
2326
  */
2253
2327
  const createSubgraph = (options) => {
2254
2328
  return (options.client ?? client_gen_1.client).post({
@@ -2278,6 +2352,7 @@ exports.createSubgraph = createSubgraph;
2278
2352
  * **Requirements:**
2279
2353
  * - Must be a valid subgraph (not parent graph)
2280
2354
  * - User must have admin access to parent graph
2355
+ * - Subgraph name must be alphanumeric (1-20 characters)
2281
2356
  * - Optional backup before deletion
2282
2357
  *
2283
2358
  * **Deletion Options:**
@@ -2291,6 +2366,11 @@ exports.createSubgraph = createSubgraph;
2291
2366
  * **Backup Location:**
2292
2367
  * If backup requested, stored in S3 Kuzu database bucket at:
2293
2368
  * `s3://{kuzu_s3_bucket}/{instance_id}/{database_name}_{timestamp}.backup`
2369
+ *
2370
+ * **Notes:**
2371
+ * - Use the subgraph name (e.g., 'dev', 'staging') not the full subgraph ID
2372
+ * - Deletion does not affect parent graph's credit pool or permissions
2373
+ * - Backup creation consumes credits from parent graph's allocation
2294
2374
  */
2295
2375
  const deleteSubgraph = (options) => {
2296
2376
  return (options.client ?? client_gen_1.client).delete({
@@ -2304,7 +2384,7 @@ const deleteSubgraph = (options) => {
2304
2384
  type: 'http'
2305
2385
  }
2306
2386
  ],
2307
- url: '/v1/graphs/{graph_id}/subgraphs/{subgraph_id}',
2387
+ url: '/v1/graphs/{graph_id}/subgraphs/{subgraph_name}',
2308
2388
  ...options,
2309
2389
  headers: {
2310
2390
  'Content-Type': 'application/json',
@@ -2319,6 +2399,7 @@ exports.deleteSubgraph = deleteSubgraph;
2319
2399
  *
2320
2400
  * **Requirements:**
2321
2401
  * - User must have read access to parent graph
2402
+ * - Subgraph name must be alphanumeric (1-20 characters)
2322
2403
  *
2323
2404
  * **Response includes:**
2324
2405
  * - Full subgraph metadata
@@ -2334,6 +2415,10 @@ exports.deleteSubgraph = deleteSubgraph;
2334
2415
  * - Edge count
2335
2416
  * - Database size on disk
2336
2417
  * - Schema information
2418
+ *
2419
+ * **Note:**
2420
+ * Use the subgraph name (e.g., 'dev', 'staging') not the full subgraph ID.
2421
+ * The full ID is returned in the response (e.g., 'kg0123456789abcdef_dev').
2337
2422
  */
2338
2423
  const getSubgraphInfo = (options) => {
2339
2424
  return (options.client ?? client_gen_1.client).get({
@@ -2347,7 +2432,7 @@ const getSubgraphInfo = (options) => {
2347
2432
  type: 'http'
2348
2433
  }
2349
2434
  ],
2350
- url: '/v1/graphs/{graph_id}/subgraphs/{subgraph_id}/info',
2435
+ url: '/v1/graphs/{graph_id}/subgraphs/{subgraph_name}/info',
2351
2436
  ...options
2352
2437
  });
2353
2438
  };
@@ -2528,44 +2613,66 @@ const listTables = (options) => {
2528
2613
  };
2529
2614
  exports.listTables = listTables;
2530
2615
  /**
2531
- * List Files in Staging Table
2532
- * List all files uploaded to a staging table with comprehensive metadata.
2616
+ * Query Staging Tables with SQL
2617
+ * Execute SQL queries on DuckDB staging tables for data inspection and validation.
2533
2618
  *
2534
- * Get a complete inventory of all files in a staging table, including upload status,
2535
- * file sizes, row counts, and S3 locations. Essential for monitoring upload progress
2536
- * and validating data before ingestion.
2619
+ * Query raw staging data directly with SQL before ingestion into the graph database.
2620
+ * Useful for data quality checks, validation, and exploratory analysis.
2621
+ *
2622
+ * **Security Best Practice - Use Parameterized Queries:**
2623
+ * ALWAYS use query parameters instead of string concatenation to prevent SQL injection:
2624
+ * - ✅ SAFE: `SELECT * FROM Entity WHERE type = ? LIMIT ?` with `parameters: ["Company", 100]`
2625
+ * - ❌ UNSAFE: `SELECT * FROM Entity WHERE type = 'Company' LIMIT 100` with user input concatenated into SQL string
2626
+ *
2627
+ * Query parameters provide automatic escaping and type safety. Use `?` placeholders with parameters array.
2537
2628
  *
2538
2629
  * **Use Cases:**
2539
- * - Monitor file upload progress
2540
- * - Verify files are ready for ingestion
2541
- * - Check file formats and sizes
2542
- * - Track storage usage per table
2543
- * - Identify failed or incomplete uploads
2544
- * - Pre-ingestion validation
2630
+ * - Validate data quality before graph ingestion
2631
+ * - Inspect row-level data for debugging
2632
+ * - Run analytics on staging tables
2633
+ * - Check for duplicates, nulls, or data issues
2634
+ * - Preview data transformations
2545
2635
  *
2546
- * **Returned Metadata:**
2547
- * - File ID, name, and format (parquet, csv, json)
2548
- * - Size in bytes and row count (if available)
2549
- * - Upload status and method
2550
- * - Creation and upload timestamps
2551
- * - S3 key for reference
2636
+ * **Workflow:**
2637
+ * 1. Upload data files via `POST /tables/{table_name}/files`
2638
+ * 2. Query staging tables to validate: `POST /tables/query`
2639
+ * 3. Fix any data issues by re-uploading
2640
+ * 4. Ingest validated data: `POST /tables/ingest`
2552
2641
  *
2553
- * **Upload Status Values:**
2554
- * - `pending`: Upload URL generated, awaiting upload
2555
- * - `uploaded`: Successfully uploaded, ready for ingestion
2556
- * - `disabled`: Excluded from ingestion
2557
- * - `archived`: Soft deleted
2558
- * - `failed`: Upload failed
2642
+ * **Supported SQL:**
2643
+ * - Full DuckDB SQL syntax
2644
+ * - SELECT, JOIN, WHERE, GROUP BY, ORDER BY
2645
+ * - Aggregations, window functions, CTEs
2646
+ * - Multiple table joins across staging area
2559
2647
  *
2560
- * **Important Notes:**
2561
- * - Only `uploaded` files are ingested
2562
- * - Check `row_count` to estimate data volume
2563
- * - Use `total_size_bytes` for storage monitoring
2564
- * - Files with `failed` status should be deleted and re-uploaded
2565
- * - File listing is included - no credit consumption
2648
+ * **Common Operations:**
2649
+ * - Count rows: `SELECT COUNT(*) FROM Entity`
2650
+ * - Filter by type: `SELECT * FROM Entity WHERE entity_type = ? LIMIT ?` with `parameters: ["Company", 100]`
2651
+ * - Check for nulls: `SELECT * FROM Entity WHERE name IS NULL LIMIT 10`
2652
+ * - Find duplicates: `SELECT identifier, COUNT(*) as cnt FROM Entity GROUP BY identifier HAVING COUNT(*) > 1`
2653
+ * - Filter amounts: `SELECT * FROM Transaction WHERE amount > ? AND date >= ?` with `parameters: [1000, "2024-01-01"]`
2654
+ *
2655
+ * **Limits:**
2656
+ * - Query timeout: 30 seconds
2657
+ * - Result limit: 10,000 rows (use LIMIT clause)
2658
+ * - Read-only: No INSERT, UPDATE, DELETE
2659
+ * - User's tables only: Cannot query other users' data
2660
+ *
2661
+ * **Subgraph Support:**
2662
+ * This endpoint accepts both parent graph IDs and subgraph IDs.
2663
+ * - Parent graph: Use `graph_id` like `kg0123456789abcdef`
2664
+ * - Subgraph: Use full subgraph ID like `kg0123456789abcdef_dev`
2665
+ * Each subgraph has its own independent staging tables.
2666
+ *
2667
+ * **Shared Repositories:**
2668
+ * Shared repositories (SEC, etc.) do not allow direct SQL queries.
2669
+ * Use the graph query endpoint instead: `POST /v1/graphs/{graph_id}/query`
2670
+ *
2671
+ * **Note:**
2672
+ * Staging table queries are included - no credit consumption
2566
2673
  */
2567
- const listTableFiles = (options) => {
2568
- return (options.client ?? client_gen_1.client).get({
2674
+ const queryTables = (options) => {
2675
+ return (options.client ?? client_gen_1.client).post({
2569
2676
  security: [
2570
2677
  {
2571
2678
  name: 'X-API-Key',
@@ -2576,48 +2683,35 @@ const listTableFiles = (options) => {
2576
2683
  type: 'http'
2577
2684
  }
2578
2685
  ],
2579
- url: '/v1/graphs/{graph_id}/tables/{table_name}/files',
2580
- ...options
2686
+ url: '/v1/graphs/{graph_id}/tables/query',
2687
+ ...options,
2688
+ headers: {
2689
+ 'Content-Type': 'application/json',
2690
+ ...options.headers
2691
+ }
2581
2692
  });
2582
2693
  };
2583
- exports.listTableFiles = listTableFiles;
2694
+ exports.queryTables = queryTables;
2584
2695
  /**
2585
- * Get File Upload URL
2586
- * Generate a presigned S3 URL for secure file upload.
2587
- *
2588
- * Initiates file upload to a staging table by generating a secure, time-limited
2589
- * presigned S3 URL. Files are uploaded directly to S3, bypassing the API for
2590
- * optimal performance.
2696
+ * Create View
2697
+ * Generate financial report view from data source (dual-mode support).
2591
2698
  *
2592
- * **Upload Workflow:**
2593
- * 1. Call this endpoint to get presigned URL
2594
- * 2. PUT file directly to S3 URL
2595
- * 3. Call PATCH /tables/files/{file_id} with status='uploaded'
2596
- * 4. Backend validates file and calculates metrics
2597
- * 5. File ready for ingestion
2699
+ * **Mode 1: Transaction Aggregation (generate_from_transactions)**
2700
+ * - Aggregates raw transaction data to trial balance
2701
+ * - Creates facts on-demand
2702
+ * - Shows real-time reporting from source of truth
2598
2703
  *
2599
- * **Supported Formats:**
2600
- * - Parquet (`application/x-parquet` with `.parquet` extension)
2601
- * - CSV (`text/csv` with `.csv` extension)
2602
- * - JSON (`application/json` with `.json` extension)
2603
- *
2604
- * **Validation:**
2605
- * - File extension must match content type
2606
- * - File name 1-255 characters
2607
- * - No path traversal characters (.. / \)
2608
- * - Auto-creates table if it doesn't exist
2609
- *
2610
- * **Auto-Table Creation:**
2611
- * Tables are automatically created on first file upload with type inferred from name
2612
- * (e.g., "Transaction" → relationship) and empty schema populated during ingestion.
2704
+ * **Mode 2: Existing Facts (pivot_existing_facts)**
2705
+ * - Queries existing Fact nodes
2706
+ * - Supports multi-dimensional analysis
2707
+ * - Works with SEC filings and pre-computed facts
2613
2708
  *
2614
- * **Important Notes:**
2615
- * - Presigned URLs expire (default: 1 hour)
2616
- * - Use appropriate Content-Type header when uploading to S3
2617
- * - File extension must match content type
2618
- * - Upload URL generation is included - no credit consumption
2709
+ * Both modes:
2710
+ * - Build FactGrid from data
2711
+ * - Generate pivot table presentation
2712
+ * - Return consistent response format
2619
2713
  */
2620
- const getUploadUrl = (options) => {
2714
+ const createView = (options) => {
2621
2715
  return (options.client ?? client_gen_1.client).post({
2622
2716
  security: [
2623
2717
  {
@@ -2629,7 +2723,7 @@ const getUploadUrl = (options) => {
2629
2723
  type: 'http'
2630
2724
  }
2631
2725
  ],
2632
- url: '/v1/graphs/{graph_id}/tables/{table_name}/files',
2726
+ url: '/v1/graphs/{graph_id}/views',
2633
2727
  ...options,
2634
2728
  headers: {
2635
2729
  'Content-Type': 'application/json',
@@ -2637,43 +2731,41 @@ const getUploadUrl = (options) => {
2637
2731
  }
2638
2732
  });
2639
2733
  };
2640
- exports.getUploadUrl = getUploadUrl;
2734
+ exports.createView = createView;
2641
2735
  /**
2642
- * Delete File from Staging
2643
- * Delete a file from S3 storage and database tracking.
2736
+ * Save View
2737
+ * Save or update view as materialized report in the graph.
2644
2738
  *
2645
- * Remove unwanted, duplicate, or incorrect files from staging tables before ingestion.
2646
- * The file is deleted from both S3 and database tracking, and table statistics
2647
- * are automatically recalculated.
2739
+ * Converts computed view results into persistent Report, Fact, and Structure nodes.
2740
+ * This establishes what data exists in the subgraph, which then defines what
2741
+ * needs to be exported for publishing to the parent graph.
2648
2742
  *
2649
- * **Use Cases:**
2650
- * - Remove duplicate uploads
2651
- * - Delete files with incorrect data
2652
- * - Clean up failed uploads
2653
- * - Fix data quality issues before ingestion
2654
- * - Manage storage usage
2743
+ * **Create Mode** (no report_id provided):
2744
+ * - Generates new report_id from entity + period + report type
2745
+ * - Creates new Report, Facts, and Structures
2655
2746
  *
2656
- * **What Happens:**
2657
- * 1. File deleted from S3 storage
2658
- * 2. Database tracking record removed
2659
- * 3. Table statistics recalculated (file count, size, row count)
2660
- * 4. DuckDB automatically excludes file from future queries
2747
+ * **Update Mode** (report_id provided):
2748
+ * - Deletes all existing Facts and Structures for the report
2749
+ * - Updates Report metadata
2750
+ * - Creates fresh Facts and Structures from current view
2751
+ * - Useful for refreshing reports with updated data or view configurations
2661
2752
  *
2662
- * **Security:**
2663
- * - Write access required (verified via auth)
2664
- * - Shared repositories block file deletions
2665
- * - Full audit trail of deletion operations
2666
- * - Cannot delete after ingestion to graph
2753
+ * **This is NOT publishing** - it only creates nodes in the subgraph workspace.
2754
+ * Publishing (export parquet parent ingest) happens separately.
2667
2755
  *
2668
- * **Important Notes:**
2669
- * - Delete files before ingestion for best results
2670
- * - Table statistics update automatically
2671
- * - No need to refresh DuckDB - exclusion is automatic
2672
- * - Consider re-uploading corrected version after deletion
2673
- * - File deletion is included - no credit consumption
2756
+ * Creates/Updates:
2757
+ * - Report node with metadata
2758
+ * - Fact nodes with all aspects (period, entity, element, unit)
2759
+ * - PresentationStructure nodes (how facts are displayed)
2760
+ * - CalculationStructure nodes (how facts roll up)
2761
+ *
2762
+ * Returns:
2763
+ * - report_id: Unique identifier used as parquet export prefix
2764
+ * - parquet_export_prefix: Filename prefix for future exports
2765
+ * - All created facts and structures
2674
2766
  */
2675
- const deleteFile = (options) => {
2676
- return (options.client ?? client_gen_1.client).delete({
2767
+ const saveView = (options) => {
2768
+ return (options.client ?? client_gen_1.client).post({
2677
2769
  security: [
2678
2770
  {
2679
2771
  name: 'X-API-Key',
@@ -2684,30 +2776,43 @@ const deleteFile = (options) => {
2684
2776
  type: 'http'
2685
2777
  }
2686
2778
  ],
2687
- url: '/v1/graphs/{graph_id}/tables/files/{file_id}',
2688
- ...options
2779
+ url: '/v1/graphs/{graph_id}/views/save',
2780
+ ...options,
2781
+ headers: {
2782
+ 'Content-Type': 'application/json',
2783
+ ...options.headers
2784
+ }
2689
2785
  });
2690
2786
  };
2691
- exports.deleteFile = deleteFile;
2787
+ exports.saveView = saveView;
2692
2788
  /**
2693
- * Get File Information
2694
- * Get detailed information about a specific file.
2789
+ * Get Materialization Status
2790
+ * Get current materialization status for the graph.
2695
2791
  *
2696
- * Retrieve comprehensive metadata for a single file, including upload status,
2697
- * size, row count, and timestamps. Useful for validating individual files
2698
- * before ingestion.
2792
+ * Shows whether the graph is stale (DuckDB has changes not yet in graph database),
2793
+ * when it was last materialized, and how long since last materialization.
2794
+ *
2795
+ * **Status Information:**
2796
+ * - Whether graph is currently stale
2797
+ * - Reason for staleness if applicable
2798
+ * - When graph became stale
2799
+ * - When graph was last materialized
2800
+ * - Total materialization count
2801
+ * - Hours since last materialization
2699
2802
  *
2700
2803
  * **Use Cases:**
2701
- * - Validate file upload completion
2702
- * - Check file metadata before ingestion
2703
- * - Debug upload issues
2704
- * - Verify file format and size
2705
- * - Track file lifecycle
2804
+ * - Decide if materialization is needed
2805
+ * - Monitor graph freshness
2806
+ * - Track materialization history
2807
+ * - Understand data pipeline state
2706
2808
  *
2707
- * **Note:**
2708
- * File info retrieval is included - no credit consumption
2809
+ * **Important Notes:**
2810
+ * - Stale graph means DuckDB has changes not in graph
2811
+ * - Graph becomes stale after file deletions
2812
+ * - Materialization clears staleness
2813
+ * - Status retrieval is included - no credit consumption
2709
2814
  */
2710
- const getFileInfo = (options) => {
2815
+ const getMaterializationStatus = (options) => {
2711
2816
  return (options.client ?? client_gen_1.client).get({
2712
2817
  security: [
2713
2818
  {
@@ -2719,52 +2824,67 @@ const getFileInfo = (options) => {
2719
2824
  type: 'http'
2720
2825
  }
2721
2826
  ],
2722
- url: '/v1/graphs/{graph_id}/tables/files/{file_id}',
2827
+ url: '/v1/graphs/{graph_id}/materialize/status',
2723
2828
  ...options
2724
2829
  });
2725
2830
  };
2726
- exports.getFileInfo = getFileInfo;
2831
+ exports.getMaterializationStatus = getMaterializationStatus;
2727
2832
  /**
2728
- * Update File Upload Status
2729
- * Update file status after upload completes.
2833
+ * Materialize Graph from DuckDB
2834
+ * Rebuild entire graph from DuckDB staging tables (materialized view pattern).
2730
2835
  *
2731
- * Marks files as uploaded after successful S3 upload. The backend validates
2732
- * the file, calculates size and row count, enforces storage limits, and
2733
- * registers the DuckDB table for queries.
2836
+ * This endpoint rebuilds the complete graph database from the current state of DuckDB
2837
+ * staging tables. It automatically discovers all tables, ingests them in the correct
2838
+ * order (nodes before relationships), and clears the staleness flag.
2734
2839
  *
2735
- * **Status Values:**
2736
- * - `uploaded`: File successfully uploaded to S3 (triggers validation)
2737
- * - `disabled`: Exclude file from ingestion
2738
- * - `archived`: Soft delete file
2739
- *
2740
- * **What Happens on 'uploaded' Status:**
2741
- * 1. Verify file exists in S3
2742
- * 2. Calculate actual file size
2743
- * 3. Enforce tier storage limits
2744
- * 4. Calculate or estimate row count
2745
- * 5. Update table statistics
2746
- * 6. Register DuckDB external table
2747
- * 7. File ready for ingestion
2748
- *
2749
- * **Row Count Calculation:**
2750
- * - **Parquet**: Exact count from file metadata
2751
- * - **CSV**: Count rows (minus header)
2752
- * - **JSON**: Count array elements
2753
- * - **Fallback**: Estimate from file size if reading fails
2754
- *
2755
- * **Storage Limits:**
2756
- * Enforced per subscription tier. Returns HTTP 413 if limit exceeded.
2757
- * Check current usage before large uploads.
2840
+ * **When to Use:**
2841
+ * - After batch uploads (files uploaded with ingest_to_graph=false)
2842
+ * - After cascade file deletions (graph marked stale)
2843
+ * - To ensure graph consistency with DuckDB state
2844
+ * - Periodic full refresh
2758
2845
  *
2759
- * **Important Notes:**
2760
- * - Always call this after S3 upload completes
2761
- * - Check response for actual row count
2762
- * - Storage limit errors (413) mean tier upgrade needed
2763
- * - DuckDB registration failures are non-fatal (retried later)
2764
- * - Status updates are included - no credit consumption
2846
+ * **What Happens:**
2847
+ * 1. Discovers all tables for the graph from PostgreSQL registry
2848
+ * 2. Sorts tables (nodes before relationships)
2849
+ * 3. Ingests all tables from DuckDB to graph in order
2850
+ * 4. Clears staleness flag on success
2851
+ * 5. Returns detailed materialization report
2852
+ *
2853
+ * **Staleness Check:**
2854
+ * By default, only materializes if graph is stale (after deletions or missed ingestions).
2855
+ * Use `force=true` to rebuild regardless of staleness.
2856
+ *
2857
+ * **Rebuild Feature:**
2858
+ * Setting `rebuild=true` regenerates the entire graph database from scratch:
2859
+ * - Deletes existing graph database
2860
+ * - Recreates with fresh schema from active GraphSchema
2861
+ * - Ingests all data files
2862
+ * - Safe operation - DuckDB is source of truth
2863
+ * - Useful for schema changes or data corrections
2864
+ * - Graph marked as 'rebuilding' during process
2865
+ *
2866
+ * **Table Ordering:**
2867
+ * Node tables (PascalCase) are ingested before relationship tables (UPPERCASE) to
2868
+ * ensure referential integrity.
2869
+ *
2870
+ * **Error Handling:**
2871
+ * With `ignore_errors=true` (default), continues materializing even if individual
2872
+ * rows fail. Failed rows are logged but don't stop the process.
2873
+ *
2874
+ * **Concurrency Control:**
2875
+ * Only one materialization can run per graph at a time. If another materialization is in progress,
2876
+ * you'll receive a 409 Conflict error. The distributed lock automatically expires after
2877
+ * the configured TTL (default: 1 hour) to prevent deadlocks from failed materializations.
2878
+ *
2879
+ * **Performance:**
2880
+ * Full graph materialization can take minutes for large datasets. Consider running
2881
+ * during off-peak hours for production systems.
2882
+ *
2883
+ * **Credits:**
2884
+ * Materialization is included - no credit consumption
2765
2885
  */
2766
- const updateFileStatus = (options) => {
2767
- return (options.client ?? client_gen_1.client).patch({
2886
+ const materializeGraph = (options) => {
2887
+ return (options.client ?? client_gen_1.client).post({
2768
2888
  security: [
2769
2889
  {
2770
2890
  name: 'X-API-Key',
@@ -2775,7 +2895,7 @@ const updateFileStatus = (options) => {
2775
2895
  type: 'http'
2776
2896
  }
2777
2897
  ],
2778
- url: '/v1/graphs/{graph_id}/tables/files/{file_id}',
2898
+ url: '/v1/graphs/{graph_id}/materialize',
2779
2899
  ...options,
2780
2900
  headers: {
2781
2901
  'Content-Type': 'application/json',
@@ -2783,66 +2903,89 @@ const updateFileStatus = (options) => {
2783
2903
  }
2784
2904
  });
2785
2905
  };
2786
- exports.updateFileStatus = updateFileStatus;
2906
+ exports.materializeGraph = materializeGraph;
2787
2907
  /**
2788
- * Ingest Tables to Graph
2789
- * Load all files from S3 into DuckDB staging tables and ingest into Kuzu graph database.
2908
+ * List Files in Graph
2909
+ * List all files in the graph with optional filtering.
2790
2910
  *
2791
- * Orchestrates the complete data pipeline from S3 staging files into the Kuzu graph database.
2792
- * Processes all tables in a single bulk operation with comprehensive error handling and metrics.
2911
+ * Get a complete inventory of files across all tables or filtered by table name,
2912
+ * status, or other criteria. Files are first-class resources with independent lifecycle.
2913
+ *
2914
+ * **Query Parameters:**
2915
+ * - `table_name` (optional): Filter by table name
2916
+ * - `status` (optional): Filter by upload status (uploaded, pending, failed, etc.)
2793
2917
  *
2794
2918
  * **Use Cases:**
2795
- * - Initial graph population from uploaded data
2796
- * - Incremental data updates with new files
2797
- * - Complete database rebuild from source files
2798
- * - Recovery from failed ingestion attempts
2919
+ * - Monitor file upload progress across all tables
2920
+ * - Verify files are ready for ingestion
2921
+ * - Check file metadata and sizes
2922
+ * - Track storage usage per graph
2923
+ * - Identify failed or incomplete uploads
2924
+ * - Audit file provenance
2799
2925
  *
2800
- * **Workflow:**
2801
- * 1. Upload data files via `POST /tables/{table_name}/files`
2802
- * 2. Files are validated and marked as 'uploaded'
2803
- * 3. Trigger ingestion: `POST /tables/ingest`
2804
- * 4. DuckDB staging tables created from S3 patterns
2805
- * 5. Data copied row-by-row from DuckDB to Kuzu
2806
- * 6. Per-table results and metrics returned
2926
+ * **Returned Metadata:**
2927
+ * - File ID, name, and format (parquet, csv, json)
2928
+ * - Size in bytes and row count (if available)
2929
+ * - Upload status and timestamps
2930
+ * - DuckDB and graph ingestion status
2931
+ * - Table association
2807
2932
  *
2808
- * **Rebuild Feature:**
2809
- * Setting `rebuild=true` regenerates the entire graph database from scratch:
2810
- * - Deletes existing Kuzu database
2811
- * - Recreates with fresh schema from active GraphSchema
2812
- * - Ingests all data files
2813
- * - Safe operation - S3 is source of truth
2814
- * - Useful for schema changes or data corrections
2815
- * - Graph marked as 'rebuilding' during process
2933
+ * **File Lifecycle Tracking:**
2934
+ * Multi-layer status across S3 DuckDB Graph pipeline
2816
2935
  *
2817
- * **Error Handling:**
2818
- * - Per-table error isolation with `ignore_errors` flag
2819
- * - Partial success support (some tables succeed, some fail)
2820
- * - Detailed error reporting per table
2821
- * - Graph status tracking throughout process
2822
- * - Automatic failure recovery and cleanup
2936
+ * **Important Notes:**
2937
+ * - Files are graph-scoped, not table-scoped
2938
+ * - Use table_name parameter to filter by table
2939
+ * - File listing is included - no credit consumption
2940
+ */
2941
+ const listFiles = (options) => {
2942
+ return (options.client ?? client_gen_1.client).get({
2943
+ security: [
2944
+ {
2945
+ name: 'X-API-Key',
2946
+ type: 'apiKey'
2947
+ },
2948
+ {
2949
+ scheme: 'bearer',
2950
+ type: 'http'
2951
+ }
2952
+ ],
2953
+ url: '/v1/graphs/{graph_id}/files',
2954
+ ...options
2955
+ });
2956
+ };
2957
+ exports.listFiles = listFiles;
2958
+ /**
2959
+ * Create File Upload
2960
+ * Generate presigned S3 URL for file upload.
2823
2961
  *
2824
- * **Performance:**
2825
- * - Processes all tables in sequence
2826
- * - Each table timed independently
2827
- * - Total execution metrics provided
2828
- * - Scales to thousands of files
2829
- * - Optimized for large datasets
2962
+ * Initiate file upload by generating a secure, time-limited presigned S3 URL.
2963
+ * Files are first-class resources uploaded directly to S3.
2830
2964
  *
2831
- * **Concurrency Control:**
2832
- * Only one ingestion can run per graph at a time. If another ingestion is in progress,
2833
- * you'll receive a 409 Conflict error. The distributed lock automatically expires after
2834
- * the configured TTL (default: 1 hour) to prevent deadlocks from failed ingestions.
2965
+ * **Request Body:**
2966
+ * - `file_name`: Name of the file (1-255 characters)
2967
+ * - `file_format`: Format (parquet, csv, json)
2968
+ * - `table_name`: Table to associate file with
2969
+ *
2970
+ * **Upload Workflow:**
2971
+ * 1. Call this endpoint to get presigned URL
2972
+ * 2. PUT file directly to S3 URL
2973
+ * 3. Call PATCH /files/{file_id} with status='uploaded'
2974
+ * 4. Backend validates and stages in DuckDB immediately
2975
+ * 5. Background task ingests to graph
2976
+ *
2977
+ * **Supported Formats:**
2978
+ * - Parquet, CSV, JSON
2979
+ *
2980
+ * **Auto-Table Creation:**
2981
+ * Tables are automatically created if they don't exist.
2835
2982
  *
2836
2983
  * **Important Notes:**
2837
- * - Only files with 'uploaded' status are processed
2838
- * - Tables with no uploaded files are skipped
2839
- * - Use `ignore_errors=false` for strict validation
2840
- * - Monitor progress via per-table results
2841
- * - Check graph metadata for rebuild status
2842
- * - Wait for current ingestion to complete before starting another
2843
- * - Table ingestion is included - no credit consumption
2844
- */
2845
- const ingestTables = (options) => {
2984
+ * - Presigned URLs expire (default: 1 hour)
2985
+ * - Files are graph-scoped, independent resources
2986
+ * - Upload URL generation is included - no credit consumption
2987
+ */
2988
+ const createFileUpload = (options) => {
2846
2989
  return (options.client ?? client_gen_1.client).post({
2847
2990
  security: [
2848
2991
  {
@@ -2854,7 +2997,7 @@ const ingestTables = (options) => {
2854
2997
  type: 'http'
2855
2998
  }
2856
2999
  ],
2857
- url: '/v1/graphs/{graph_id}/tables/ingest',
3000
+ url: '/v1/graphs/{graph_id}/files',
2858
3001
  ...options,
2859
3002
  headers: {
2860
3003
  'Content-Type': 'application/json',
@@ -2862,62 +3005,102 @@ const ingestTables = (options) => {
2862
3005
  }
2863
3006
  });
2864
3007
  };
2865
- exports.ingestTables = ingestTables;
3008
+ exports.createFileUpload = createFileUpload;
2866
3009
  /**
2867
- * Query Staging Tables with SQL
2868
- * Execute SQL queries on DuckDB staging tables for data inspection and validation.
3010
+ * Delete File
3011
+ * Delete file from all layers.
2869
3012
  *
2870
- * Query raw staging data directly with SQL before ingestion into the graph database.
2871
- * Useful for data quality checks, validation, and exploratory analysis.
3013
+ * Remove file from S3, database tracking, and optionally from DuckDB and graph.
3014
+ * Files are deleted by file_id, independent of table context.
2872
3015
  *
2873
- * **Security Best Practice - Use Parameterized Queries:**
2874
- * ALWAYS use query parameters instead of string concatenation to prevent SQL injection:
2875
- * - ✅ SAFE: `SELECT * FROM Entity WHERE type = ? LIMIT ?` with `parameters: ["Company", 100]`
2876
- * - ❌ UNSAFE: `SELECT * FROM Entity WHERE type = 'Company' LIMIT 100` with user input concatenated into SQL string
3016
+ * **Query Parameters:**
3017
+ * - `cascade` (optional, default=false): Delete from all layers including DuckDB
2877
3018
  *
2878
- * Query parameters provide automatic escaping and type safety. Use `?` placeholders with parameters array.
3019
+ * **What Happens (cascade=false):**
3020
+ * 1. File deleted from S3
3021
+ * 2. Database record removed
3022
+ * 3. Table statistics updated
3023
+ *
3024
+ * **What Happens (cascade=true):**
3025
+ * 1. File data deleted from all DuckDB tables (by file_id)
3026
+ * 2. Graph marked as stale
3027
+ * 3. File deleted from S3
3028
+ * 4. Database record removed
3029
+ * 5. Table statistics updated
2879
3030
  *
2880
3031
  * **Use Cases:**
2881
- * - Validate data quality before graph ingestion
2882
- * - Inspect row-level data for debugging
2883
- * - Run analytics on staging tables
2884
- * - Check for duplicates, nulls, or data issues
2885
- * - Preview data transformations
3032
+ * - Remove incorrect or duplicate files
3033
+ * - Clean up failed uploads
3034
+ * - Delete files before graph ingestion
3035
+ * - Surgical data removal with cascade
2886
3036
  *
2887
- * **Workflow:**
2888
- * 1. Upload data files via `POST /tables/{table_name}/files`
2889
- * 2. Query staging tables to validate: `POST /tables/query`
2890
- * 3. Fix any data issues by re-uploading
2891
- * 4. Ingest validated data: `POST /tables/ingest`
3037
+ * **Security:**
3038
+ * - Write access required
3039
+ * - Shared repositories block deletions
3040
+ * - Full audit trail
2892
3041
  *
2893
- * **Supported SQL:**
2894
- * - Full DuckDB SQL syntax
2895
- * - SELECT, JOIN, WHERE, GROUP BY, ORDER BY
2896
- * - Aggregations, window functions, CTEs
2897
- * - Multiple table joins across staging area
3042
+ * **Important:**
3043
+ * - Use cascade=true for immediate DuckDB cleanup
3044
+ * - Graph rebuild recommended after cascade deletion
3045
+ * - File deletion is included - no credit consumption
3046
+ */
3047
+ const deleteFile = (options) => {
3048
+ return (options.client ?? client_gen_1.client).delete({
3049
+ security: [
3050
+ {
3051
+ name: 'X-API-Key',
3052
+ type: 'apiKey'
3053
+ },
3054
+ {
3055
+ scheme: 'bearer',
3056
+ type: 'http'
3057
+ }
3058
+ ],
3059
+ url: '/v1/graphs/{graph_id}/files/{file_id}',
3060
+ ...options
3061
+ });
3062
+ };
3063
+ exports.deleteFile = deleteFile;
3064
+ /**
3065
+ * Get File Information
3066
+ * Get detailed information about a specific file.
2898
3067
  *
2899
- * **Common Operations:**
2900
- * - Count rows: `SELECT COUNT(*) FROM Entity`
2901
- * - Filter by type: `SELECT * FROM Entity WHERE entity_type = ? LIMIT ?` with `parameters: ["Company", 100]`
2902
- * - Check for nulls: `SELECT * FROM Entity WHERE name IS NULL LIMIT 10`
2903
- * - Find duplicates: `SELECT identifier, COUNT(*) as cnt FROM Entity GROUP BY identifier HAVING COUNT(*) > 1`
2904
- * - Filter amounts: `SELECT * FROM Transaction WHERE amount > ? AND date >= ?` with `parameters: [1000, "2024-01-01"]`
3068
+ * Retrieve comprehensive metadata for a single file by file_id, independent of
3069
+ * table context. Files are first-class resources with complete lifecycle tracking.
2905
3070
  *
2906
- * **Limits:**
2907
- * - Query timeout: 30 seconds
2908
- * - Result limit: 10,000 rows (use LIMIT clause)
2909
- * - Read-only: No INSERT, UPDATE, DELETE
2910
- * - User's tables only: Cannot query other users' data
3071
+ * **Returned Information:**
3072
+ * - File ID, name, format, size
3073
+ * - Upload status and timestamps
3074
+ * - **Enhanced Multi-Layer Status** (new in this version):
3075
+ * - S3 layer: upload_status, uploaded_at, size_bytes, row_count
3076
+ * - DuckDB layer: duckdb_status, duckdb_staged_at, duckdb_row_count
3077
+ * - Graph layer: graph_status, graph_ingested_at
3078
+ * - Table association
3079
+ * - S3 location
3080
+ *
3081
+ * **Multi-Layer Pipeline Visibility:**
3082
+ * The `layers` object provides independent status tracking across the three-tier
3083
+ * data pipeline:
3084
+ * - **S3 (Immutable Source)**: File upload and validation
3085
+ * - **DuckDB (Mutable Staging)**: Immediate queryability with file provenance
3086
+ * - **Graph (Immutable View)**: Optional graph database materialization
3087
+ *
3088
+ * Each layer shows its own status, timestamp, and row count (where applicable),
3089
+ * enabling precise debugging and monitoring of the data ingestion flow.
2911
3090
  *
2912
- * **Shared Repositories:**
2913
- * Shared repositories (SEC, etc.) do not allow direct SQL queries.
2914
- * Use the graph query endpoint instead: `POST /v1/graphs/{graph_id}/query`
3091
+ * **Use Cases:**
3092
+ * - Validate file upload completion
3093
+ * - Monitor multi-layer ingestion progress in real-time
3094
+ * - Debug upload or staging issues at specific layers
3095
+ * - Verify file metadata and row counts
3096
+ * - Track file provenance through the pipeline
3097
+ * - Identify bottlenecks in the ingestion process
2915
3098
  *
2916
3099
  * **Note:**
2917
- * Staging table queries are included - no credit consumption
3100
+ * File info retrieval is included - no credit consumption
2918
3101
  */
2919
- const queryTables = (options) => {
2920
- return (options.client ?? client_gen_1.client).post({
3102
+ const getFile = (options) => {
3103
+ return (options.client ?? client_gen_1.client).get({
2921
3104
  security: [
2922
3105
  {
2923
3106
  name: 'X-API-Key',
@@ -2928,7 +3111,53 @@ const queryTables = (options) => {
2928
3111
  type: 'http'
2929
3112
  }
2930
3113
  ],
2931
- url: '/v1/graphs/{graph_id}/tables/query',
3114
+ url: '/v1/graphs/{graph_id}/files/{file_id}',
3115
+ ...options
3116
+ });
3117
+ };
3118
+ exports.getFile = getFile;
3119
+ /**
3120
+ * Update File Status
3121
+ * Update file status and trigger processing.
3122
+ *
3123
+ * Update file status after upload completion. Setting status='uploaded' triggers
3124
+ * immediate DuckDB staging and optional graph ingestion.
3125
+ *
3126
+ * **Request Body:**
3127
+ * - `status`: New status (uploaded, disabled, failed)
3128
+ * - `ingest_to_graph` (optional): If true, auto-ingest to graph after DuckDB staging
3129
+ *
3130
+ * **What Happens (status='uploaded'):**
3131
+ * 1. File validated in S3
3132
+ * 2. Row count calculated
3133
+ * 3. DuckDB staging triggered immediately (Celery task)
3134
+ * 4. If ingest_to_graph=true, graph ingestion queued
3135
+ * 5. File queryable in DuckDB within seconds
3136
+ *
3137
+ * **Use Cases:**
3138
+ * - Signal upload completion
3139
+ * - Trigger immediate DuckDB staging
3140
+ * - Enable/disable files
3141
+ * - Mark failed uploads
3142
+ *
3143
+ * **Important:**
3144
+ * - Files must exist in S3 before marking uploaded
3145
+ * - DuckDB staging happens asynchronously
3146
+ * - Graph ingestion is optional (ingest_to_graph flag)
3147
+ */
3148
+ const updateFile = (options) => {
3149
+ return (options.client ?? client_gen_1.client).patch({
3150
+ security: [
3151
+ {
3152
+ name: 'X-API-Key',
3153
+ type: 'apiKey'
3154
+ },
3155
+ {
3156
+ scheme: 'bearer',
3157
+ type: 'http'
3158
+ }
3159
+ ],
3160
+ url: '/v1/graphs/{graph_id}/files/{file_id}',
2932
3161
  ...options,
2933
3162
  headers: {
2934
3163
  'Content-Type': 'application/json',
@@ -2936,7 +3165,7 @@ const queryTables = (options) => {
2936
3165
  }
2937
3166
  });
2938
3167
  };
2939
- exports.queryTables = queryTables;
3168
+ exports.updateFile = updateFile;
2940
3169
  /**
2941
3170
  * Get User Graphs and Repositories
2942
3171
  * List all graph databases and shared repositories accessible to the current user.