@robosystems/client 0.2.0 → 0.2.2

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.
Files changed (37) hide show
  1. package/extensions/GraphClient.d.ts +71 -0
  2. package/extensions/GraphClient.js +176 -0
  3. package/extensions/GraphClient.test.ts +285 -0
  4. package/extensions/GraphClient.ts +281 -0
  5. package/extensions/TableIngestClient.d.ts +1 -1
  6. package/extensions/TableIngestClient.js +20 -20
  7. package/extensions/TableIngestClient.test.ts +1 -1
  8. package/extensions/TableIngestClient.ts +23 -28
  9. package/extensions/hooks.d.ts +1 -1
  10. package/extensions/index.d.ts +5 -1
  11. package/extensions/index.js +14 -1
  12. package/extensions/index.test.ts +22 -0
  13. package/extensions/index.ts +15 -1
  14. package/package.json +1 -1
  15. package/sdk/sdk.gen.d.ts +528 -26
  16. package/sdk/sdk.gen.js +534 -32
  17. package/sdk/sdk.gen.ts +532 -30
  18. package/sdk/types.gen.d.ts +289 -82
  19. package/sdk/types.gen.ts +293 -82
  20. package/sdk-extensions/GraphClient.d.ts +71 -0
  21. package/sdk-extensions/GraphClient.js +176 -0
  22. package/sdk-extensions/GraphClient.test.ts +285 -0
  23. package/sdk-extensions/GraphClient.ts +281 -0
  24. package/sdk-extensions/TableIngestClient.d.ts +1 -1
  25. package/sdk-extensions/TableIngestClient.js +20 -20
  26. package/sdk-extensions/TableIngestClient.test.ts +1 -1
  27. package/sdk-extensions/TableIngestClient.ts +23 -28
  28. package/sdk-extensions/hooks.d.ts +1 -1
  29. package/sdk-extensions/index.d.ts +5 -1
  30. package/sdk-extensions/index.js +14 -1
  31. package/sdk-extensions/index.test.ts +22 -0
  32. package/sdk-extensions/index.ts +15 -1
  33. package/sdk.gen.d.ts +528 -26
  34. package/sdk.gen.js +534 -32
  35. package/sdk.gen.ts +532 -30
  36. package/types.gen.d.ts +289 -82
  37. package/types.gen.ts +293 -82
package/sdk.gen.js CHANGED
@@ -2,7 +2,7 @@
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.autoSelectAgent = exports.syncConnection = exports.getConnection = exports.deleteConnection = exports.oauthCallback = exports.initOAuth = exports.createLinkToken = exports.exchangeLinkToken = exports.getConnectionOptions = exports.createConnection = exports.listConnections = exports.getRepositoryCredits = exports.getSharedRepositoryCredits = exports.cancelSharedRepositorySubscription = exports.upgradeSharedRepositorySubscription = exports.subscribeToSharedRepository = exports.getUserSharedSubscriptions = exports.getDetailedUserAnalytics = exports.getUserUsageOverview = exports.getSharedRepositoryLimits = exports.getAllSharedRepositoryLimits = exports.getUserUsage = exports.getUserLimits = exports.updateUserApiKey = exports.revokeUserApiKey = exports.createUserApiKey = exports.listUserApiKeys = exports.updateUserPassword = exports.getAllCreditSummaries = 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.cancelOperation = exports.getOperationStatus = exports.streamOperationEvents = exports.getServiceOfferings = exports.selectGraph = exports.getAvailableExtensions = exports.createGraph = exports.getGraphs = exports.queryTablesV1GraphsGraphIdTablesQueryPost = exports.ingestTablesV1GraphsGraphIdTablesIngestPost = exports.updateFileV1GraphsGraphIdTablesFilesFileIdPatch = exports.getFileInfoV1GraphsGraphIdTablesFilesFileIdGet = exports.deleteFileV1GraphsGraphIdTablesFilesFileIdDelete = exports.getUploadUrlV1GraphsGraphIdTablesTableNameFilesPost = exports.listTableFilesV1GraphsGraphIdTablesTableNameFilesGet = exports.listTablesV1GraphsGraphIdTablesGet = 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.getGraphMonthlyBill = exports.getGraphBillingHistory = exports.getGraphUsageDetails = exports.getCurrentGraphBill = exports.validateSchema = exports.exportGraphSchema = exports.getGraphSchema = exports.executeCypherQuery = exports.getGraphUsageStats = exports.getGraphMetrics = exports.getBackupStats = exports.restoreBackup = exports.getBackupDownloadUrl = exports.createBackup = exports.listBackups = exports.callMcpTool = exports.listMcpTools = exports.recommendAgent = exports.getAgentMetadata = exports.listAgents = void 0;
5
+ exports.cancelOperation = exports.getOperationStatus = exports.streamOperationEvents = exports.getServiceOfferings = exports.selectGraph = exports.getAvailableExtensions = exports.createGraph = exports.getGraphs = exports.queryTables = exports.ingestTables = exports.updateFileStatus = exports.getFileInfo = exports.deleteFile = exports.getUploadUrl = exports.listTableFiles = exports.listTables = 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.getGraphMonthlyBill = exports.getGraphBillingHistory = exports.getGraphUsageDetails = exports.getCurrentGraphBill = exports.validateSchema = exports.exportGraphSchema = exports.getGraphSchema = exports.executeCypherQuery = exports.getGraphUsageStats = exports.getGraphMetrics = exports.getBackupStats = exports.restoreBackup = exports.getBackupDownloadUrl = exports.createBackup = exports.listBackups = exports.callMcpTool = exports.listMcpTools = exports.recommendAgent = exports.getAgentMetadata = exports.listAgents = void 0;
6
6
  const client_gen_1 = require("./client.gen");
7
7
  /**
8
8
  * Register New User
@@ -2389,9 +2389,74 @@ const getSubgraphQuota = (options) => {
2389
2389
  exports.getSubgraphQuota = getSubgraphQuota;
2390
2390
  /**
2391
2391
  * List Staging Tables
2392
- * List all DuckDB staging tables for a graph
2392
+ * List all DuckDB staging tables with comprehensive metrics and status.
2393
+ *
2394
+ * **Purpose:**
2395
+ * Get a complete inventory of all staging tables for a graph, including
2396
+ * file counts, storage sizes, and row estimates. Essential for monitoring
2397
+ * the data pipeline and determining which tables are ready for ingestion.
2398
+ *
2399
+ * **What You Get:**
2400
+ * - Table name and type (node/relationship)
2401
+ * - File count per table
2402
+ * - Total storage size in bytes
2403
+ * - Estimated row count
2404
+ * - S3 location pattern
2405
+ * - Ready-for-ingestion status
2406
+ *
2407
+ * **Use Cases:**
2408
+ * - Monitor data upload progress
2409
+ * - Check which tables have files ready
2410
+ * - Track storage consumption
2411
+ * - Validate pipeline before ingestion
2412
+ * - Capacity planning
2413
+ *
2414
+ * **Workflow:**
2415
+ * 1. List tables to see current state
2416
+ * 2. Upload files to empty tables
2417
+ * 3. Re-list to verify uploads
2418
+ * 4. Check file counts and sizes
2419
+ * 5. Ingest when ready
2420
+ *
2421
+ * **Example Response:**
2422
+ * ```json
2423
+ * {
2424
+ * "tables": [
2425
+ * {
2426
+ * "table_name": "Entity",
2427
+ * "row_count": 5000,
2428
+ * "file_count": 3,
2429
+ * "total_size_bytes": 2457600,
2430
+ * "s3_location": "s3://bucket/user-staging/user123/graph456/Entity***.parquet"
2431
+ * },
2432
+ * {
2433
+ * "table_name": "Transaction",
2434
+ * "row_count": 15000,
2435
+ * "file_count": 5,
2436
+ * "total_size_bytes": 8192000,
2437
+ * "s3_location": "s3://bucket/user-staging/user123/graph456/Transaction***.parquet"
2438
+ * }
2439
+ * ],
2440
+ * "total_count": 2
2441
+ * }
2442
+ * ```
2443
+ *
2444
+ * **Example Usage:**
2445
+ * ```bash
2446
+ * curl -H "Authorization: Bearer YOUR_TOKEN" \
2447
+ * https://api.robosystems.ai/v1/graphs/kg123/tables
2448
+ * ```
2449
+ *
2450
+ * **Tips:**
2451
+ * - Tables with `file_count > 0` have data ready
2452
+ * - Check `total_size_bytes` for storage monitoring
2453
+ * - Use `s3_location` to verify upload paths
2454
+ * - Empty tables (file_count=0) are skipped during ingestion
2455
+ *
2456
+ * **Note:**
2457
+ * Table queries are included - no credit consumption.
2393
2458
  */
2394
- const listTablesV1GraphsGraphIdTablesGet = (options) => {
2459
+ const listTables = (options) => {
2395
2460
  return (options.client ?? client_gen_1.client).get({
2396
2461
  security: [
2397
2462
  {
@@ -2407,12 +2472,79 @@ const listTablesV1GraphsGraphIdTablesGet = (options) => {
2407
2472
  ...options
2408
2473
  });
2409
2474
  };
2410
- exports.listTablesV1GraphsGraphIdTablesGet = listTablesV1GraphsGraphIdTablesGet;
2475
+ exports.listTables = listTables;
2411
2476
  /**
2412
- * List Files in Table
2413
- * List all files uploaded to a staging table
2477
+ * List Files in Staging Table
2478
+ * List all files uploaded to a staging table with comprehensive metadata.
2479
+ *
2480
+ * **Purpose:**
2481
+ * Get a complete inventory of all files in a staging table, including upload status,
2482
+ * file sizes, row counts, and S3 locations. Essential for monitoring upload progress
2483
+ * and validating data before ingestion.
2484
+ *
2485
+ * **Use Cases:**
2486
+ * - Monitor file upload progress
2487
+ * - Verify files are ready for ingestion
2488
+ * - Check file formats and sizes
2489
+ * - Track storage usage per table
2490
+ * - Identify failed or incomplete uploads
2491
+ * - Pre-ingestion validation
2492
+ *
2493
+ * **What You Get:**
2494
+ * - File ID and name
2495
+ * - File format (parquet, csv, etc.)
2496
+ * - Size in bytes
2497
+ * - Row count (if available)
2498
+ * - Upload status and method
2499
+ * - Creation and upload timestamps
2500
+ * - S3 key for reference
2501
+ *
2502
+ * **Upload Status Values:**
2503
+ * - `created`: File record created, not yet uploaded
2504
+ * - `uploading`: Upload in progress
2505
+ * - `uploaded`: Successfully uploaded, ready for ingestion
2506
+ * - `failed`: Upload failed
2507
+ *
2508
+ * **Example Response:**
2509
+ * ```json
2510
+ * {
2511
+ * "graph_id": "kg123",
2512
+ * "table_name": "Entity",
2513
+ * "files": [
2514
+ * {
2515
+ * "file_id": "f123",
2516
+ * "file_name": "entities_batch1.parquet",
2517
+ * "file_format": "parquet",
2518
+ * "size_bytes": 1048576,
2519
+ * "row_count": 5000,
2520
+ * "upload_status": "uploaded",
2521
+ * "upload_method": "presigned_url",
2522
+ * "created_at": "2025-10-28T10:00:00Z",
2523
+ * "uploaded_at": "2025-10-28T10:01:30Z",
2524
+ * "s3_key": "user-staging/user123/kg123/Entity/entities_batch1.parquet"
2525
+ * }
2526
+ * ],
2527
+ * "total_files": 1,
2528
+ * "total_size_bytes": 1048576
2529
+ * }
2530
+ * ```
2531
+ *
2532
+ * **Example Usage:**
2533
+ * ```bash
2534
+ * curl -H "Authorization: Bearer YOUR_TOKEN" \
2535
+ * https://api.robosystems.ai/v1/graphs/kg123/tables/Entity/files
2536
+ * ```
2537
+ *
2538
+ * **Tips:**
2539
+ * - Only `uploaded` files are ingested
2540
+ * - Check `row_count` to estimate data volume
2541
+ * - Use `total_size_bytes` for storage monitoring
2542
+ * - Files with `failed` status should be deleted and re-uploaded
2543
+ *
2544
+ * **Note:**
2545
+ * File listing is included - no credit consumption.
2414
2546
  */
2415
- const listTableFilesV1GraphsGraphIdTablesTableNameFilesGet = (options) => {
2547
+ const listTableFiles = (options) => {
2416
2548
  return (options.client ?? client_gen_1.client).get({
2417
2549
  security: [
2418
2550
  {
@@ -2428,12 +2560,83 @@ const listTableFilesV1GraphsGraphIdTablesTableNameFilesGet = (options) => {
2428
2560
  ...options
2429
2561
  });
2430
2562
  };
2431
- exports.listTableFilesV1GraphsGraphIdTablesTableNameFilesGet = listTableFilesV1GraphsGraphIdTablesTableNameFilesGet;
2432
- /**
2433
- * Create File Upload
2434
- * Create a new file upload for a table and get a presigned S3 URL
2563
+ exports.listTableFiles = listTableFiles;
2564
+ /**
2565
+ * Get File Upload URL
2566
+ * Generate a presigned S3 URL for secure file upload.
2567
+ *
2568
+ * **Purpose:**
2569
+ * Initiate file upload to a staging table by generating a secure, time-limited
2570
+ * presigned S3 URL. Files are uploaded directly to S3, bypassing the API for
2571
+ * optimal performance.
2572
+ *
2573
+ * **Upload Workflow:**
2574
+ * 1. Call this endpoint to get presigned URL
2575
+ * 2. PUT file directly to S3 URL (using curl, axios, etc.)
2576
+ * 3. Call PATCH /tables/files/{file_id} with status='uploaded'
2577
+ * 4. Backend validates file and calculates metrics
2578
+ * 5. File ready for ingestion
2579
+ *
2580
+ * **Supported Formats:**
2581
+ * - Parquet (`application/x-parquet` with `.parquet` extension)
2582
+ * - CSV (`text/csv` with `.csv` extension)
2583
+ * - JSON (`application/json` with `.json` extension)
2584
+ *
2585
+ * **Validation:**
2586
+ * - File extension must match content type
2587
+ * - File name 1-255 characters
2588
+ * - No path traversal characters (.. / \)
2589
+ * - Auto-creates table if it doesn't exist
2590
+ *
2591
+ * **Auto-Table Creation:**
2592
+ * If the table doesn't exist, it's automatically created with:
2593
+ * - Type inferred from name (e.g., "Transaction" → relationship)
2594
+ * - Empty schema (populated on ingestion)
2595
+ * - Ready for file uploads
2596
+ *
2597
+ * **Example Response:**
2598
+ * ```json
2599
+ * {
2600
+ * "upload_url": "https://bucket.s3.amazonaws.com/path?X-Amz-Algorithm=...",
2601
+ * "expires_in": 3600,
2602
+ * "file_id": "f123-456-789",
2603
+ * "s3_key": "user-staging/user123/kg456/Entity/f123.../data.parquet"
2604
+ * }
2605
+ * ```
2606
+ *
2607
+ * **Example Usage:**
2608
+ * ```bash
2609
+ * # Step 1: Get upload URL
2610
+ * curl -X POST "https://api.robosystems.ai/v1/graphs/kg123/tables/Entity/files" \
2611
+ * -H "Authorization: Bearer YOUR_TOKEN" \
2612
+ * -H "Content-Type: application/json" \
2613
+ * -d '{
2614
+ * "file_name": "entities.parquet",
2615
+ * "content_type": "application/x-parquet"
2616
+ * }'
2617
+ *
2618
+ * # Step 2: Upload file directly to S3
2619
+ * curl -X PUT "$UPLOAD_URL" \
2620
+ * -H "Content-Type: application/x-parquet" \
2621
+ * --data-binary "@entities.parquet"
2622
+ *
2623
+ * # Step 3: Mark as uploaded
2624
+ * curl -X PATCH "https://api.robosystems.ai/v1/graphs/kg123/tables/files/$FILE_ID" \
2625
+ * -H "Authorization: Bearer YOUR_TOKEN" \
2626
+ * -H "Content-Type: application/json" \
2627
+ * -d '{"status": "uploaded"}'
2628
+ * ```
2629
+ *
2630
+ * **Tips:**
2631
+ * - Presigned URLs expire (default: 1 hour)
2632
+ * - Use appropriate Content-Type header when uploading to S3
2633
+ * - File extension must match content type
2634
+ * - Large files benefit from direct S3 upload
2635
+ *
2636
+ * **Note:**
2637
+ * Upload URL generation is included - no credit consumption.
2435
2638
  */
2436
- const getUploadUrlV1GraphsGraphIdTablesTableNameFilesPost = (options) => {
2639
+ const getUploadUrl = (options) => {
2437
2640
  return (options.client ?? client_gen_1.client).post({
2438
2641
  security: [
2439
2642
  {
@@ -2453,12 +2656,61 @@ const getUploadUrlV1GraphsGraphIdTablesTableNameFilesPost = (options) => {
2453
2656
  }
2454
2657
  });
2455
2658
  };
2456
- exports.getUploadUrlV1GraphsGraphIdTablesTableNameFilesPost = getUploadUrlV1GraphsGraphIdTablesTableNameFilesPost;
2659
+ exports.getUploadUrl = getUploadUrl;
2457
2660
  /**
2458
- * Delete File
2459
- * Delete a specific file from S3 and database tracking. DuckDB will automatically exclude it from queries.
2661
+ * Delete File from Staging
2662
+ * Delete a file from S3 storage and database tracking.
2663
+ *
2664
+ * **Purpose:**
2665
+ * Remove unwanted, duplicate, or incorrect files from staging tables before ingestion.
2666
+ * The file is deleted from both S3 and database tracking, and table statistics
2667
+ * are automatically recalculated.
2668
+ *
2669
+ * **Use Cases:**
2670
+ * - Remove duplicate uploads
2671
+ * - Delete files with incorrect data
2672
+ * - Clean up failed uploads
2673
+ * - Fix data quality issues before ingestion
2674
+ * - Manage storage usage
2675
+ *
2676
+ * **What Happens:**
2677
+ * 1. File deleted from S3 storage
2678
+ * 2. Database tracking record removed
2679
+ * 3. Table statistics recalculated (file count, size, row count)
2680
+ * 4. DuckDB automatically excludes file from future queries
2681
+ *
2682
+ * **Security:**
2683
+ * - Write access required (verified via auth)
2684
+ * - Shared repositories block file deletions
2685
+ * - Full audit trail of deletion operations
2686
+ * - Cannot delete after ingestion to graph
2687
+ *
2688
+ * **Example Response:**
2689
+ * ```json
2690
+ * {
2691
+ * "status": "deleted",
2692
+ * "file_id": "f123",
2693
+ * "file_name": "entities_batch1.parquet",
2694
+ * "message": "File deleted successfully. DuckDB will automatically exclude it from queries."
2695
+ * }
2696
+ * ```
2697
+ *
2698
+ * **Example Usage:**
2699
+ * ```bash
2700
+ * curl -X DELETE -H "Authorization: Bearer YOUR_TOKEN" \
2701
+ * https://api.robosystems.ai/v1/graphs/kg123/tables/files/f123
2702
+ * ```
2703
+ *
2704
+ * **Tips:**
2705
+ * - Delete files before ingestion for best results
2706
+ * - Table statistics update automatically
2707
+ * - No need to refresh DuckDB - exclusion is automatic
2708
+ * - Consider re-uploading corrected version after deletion
2709
+ *
2710
+ * **Note:**
2711
+ * File deletion is included - no credit consumption.
2460
2712
  */
2461
- const deleteFileV1GraphsGraphIdTablesFilesFileIdDelete = (options) => {
2713
+ const deleteFile = (options) => {
2462
2714
  return (options.client ?? client_gen_1.client).delete({
2463
2715
  security: [
2464
2716
  {
@@ -2474,12 +2726,52 @@ const deleteFileV1GraphsGraphIdTablesFilesFileIdDelete = (options) => {
2474
2726
  ...options
2475
2727
  });
2476
2728
  };
2477
- exports.deleteFileV1GraphsGraphIdTablesFilesFileIdDelete = deleteFileV1GraphsGraphIdTablesFilesFileIdDelete;
2729
+ exports.deleteFile = deleteFile;
2478
2730
  /**
2479
- * Get File Info
2480
- * Get detailed information about a specific file
2731
+ * Get File Information
2732
+ * Get detailed information about a specific file.
2733
+ *
2734
+ * **Purpose:**
2735
+ * Retrieve comprehensive metadata for a single file, including upload status,
2736
+ * size, row count, and timestamps. Useful for validating individual files
2737
+ * before ingestion.
2738
+ *
2739
+ * **Use Cases:**
2740
+ * - Validate file upload completion
2741
+ * - Check file metadata before ingestion
2742
+ * - Debug upload issues
2743
+ * - Verify file format and size
2744
+ * - Track file lifecycle
2745
+ *
2746
+ * **Example Response:**
2747
+ * ```json
2748
+ * {
2749
+ * "file_id": "f123",
2750
+ * "graph_id": "kg123",
2751
+ * "table_id": "t456",
2752
+ * "table_name": "Entity",
2753
+ * "file_name": "entities_batch1.parquet",
2754
+ * "file_format": "parquet",
2755
+ * "size_bytes": 1048576,
2756
+ * "row_count": 5000,
2757
+ * "upload_status": "uploaded",
2758
+ * "upload_method": "presigned_url",
2759
+ * "created_at": "2025-10-28T10:00:00Z",
2760
+ * "uploaded_at": "2025-10-28T10:01:30Z",
2761
+ * "s3_key": "user-staging/user123/kg123/Entity/entities_batch1.parquet"
2762
+ * }
2763
+ * ```
2764
+ *
2765
+ * **Example Usage:**
2766
+ * ```bash
2767
+ * curl -H "Authorization: Bearer YOUR_TOKEN" \
2768
+ * https://api.robosystems.ai/v1/graphs/kg123/tables/files/f123
2769
+ * ```
2770
+ *
2771
+ * **Note:**
2772
+ * File info retrieval is included - no credit consumption.
2481
2773
  */
2482
- const getFileInfoV1GraphsGraphIdTablesFilesFileIdGet = (options) => {
2774
+ const getFileInfo = (options) => {
2483
2775
  return (options.client ?? client_gen_1.client).get({
2484
2776
  security: [
2485
2777
  {
@@ -2495,12 +2787,73 @@ const getFileInfoV1GraphsGraphIdTablesFilesFileIdGet = (options) => {
2495
2787
  ...options
2496
2788
  });
2497
2789
  };
2498
- exports.getFileInfoV1GraphsGraphIdTablesFilesFileIdGet = getFileInfoV1GraphsGraphIdTablesFilesFileIdGet;
2499
- /**
2500
- * Update File
2501
- * Update file metadata after upload (size, row count). Marks file as completed.
2790
+ exports.getFileInfo = getFileInfo;
2791
+ /**
2792
+ * Update File Upload Status
2793
+ * Update file status after upload completes.
2794
+ *
2795
+ * **Purpose:**
2796
+ * Mark files as uploaded after successful S3 upload. The backend validates
2797
+ * the file, calculates size and row count, enforces storage limits, and
2798
+ * registers the DuckDB table for queries.
2799
+ *
2800
+ * **Status Values:**
2801
+ * - `uploaded`: File successfully uploaded to S3 (triggers validation)
2802
+ * - `disabled`: Exclude file from ingestion
2803
+ * - `archived`: Soft delete file
2804
+ *
2805
+ * **What Happens on 'uploaded' Status:**
2806
+ * 1. Verify file exists in S3
2807
+ * 2. Calculate actual file size
2808
+ * 3. Enforce tier storage limits
2809
+ * 4. Calculate or estimate row count
2810
+ * 5. Update table statistics
2811
+ * 6. Register DuckDB external table
2812
+ * 7. File ready for ingestion
2813
+ *
2814
+ * **Row Count Calculation:**
2815
+ * - **Parquet**: Exact count from file metadata
2816
+ * - **CSV**: Count rows (minus header)
2817
+ * - **JSON**: Count array elements
2818
+ * - **Fallback**: Estimate from file size if reading fails
2819
+ *
2820
+ * **Storage Limits:**
2821
+ * Enforced per subscription tier:
2822
+ * - Prevents uploads exceeding tier limit
2823
+ * - Returns HTTP 413 if limit exceeded
2824
+ * - Check current usage before large uploads
2825
+ *
2826
+ * **Example Response:**
2827
+ * ```json
2828
+ * {
2829
+ * "status": "success",
2830
+ * "file_id": "f123",
2831
+ * "upload_status": "uploaded",
2832
+ * "file_size_bytes": 1048576,
2833
+ * "row_count": 5000,
2834
+ * "message": "File validated and ready for ingestion"
2835
+ * }
2836
+ * ```
2837
+ *
2838
+ * **Example Usage:**
2839
+ * ```bash
2840
+ * # After uploading file to S3 presigned URL
2841
+ * curl -X PATCH "https://api.robosystems.ai/v1/graphs/kg123/tables/files/f123" \
2842
+ * -H "Authorization: Bearer YOUR_TOKEN" \
2843
+ * -H "Content-Type: application/json" \
2844
+ * -d '{"status": "uploaded"}'
2845
+ * ```
2846
+ *
2847
+ * **Tips:**
2848
+ * - Always call this after S3 upload completes
2849
+ * - Check response for actual row count
2850
+ * - Storage limit errors (413) mean tier upgrade needed
2851
+ * - DuckDB registration failures are non-fatal (retried later)
2852
+ *
2853
+ * **Note:**
2854
+ * Status updates are included - no credit consumption.
2502
2855
  */
2503
- const updateFileV1GraphsGraphIdTablesFilesFileIdPatch = (options) => {
2856
+ const updateFileStatus = (options) => {
2504
2857
  return (options.client ?? client_gen_1.client).patch({
2505
2858
  security: [
2506
2859
  {
@@ -2520,12 +2873,103 @@ const updateFileV1GraphsGraphIdTablesFilesFileIdPatch = (options) => {
2520
2873
  }
2521
2874
  });
2522
2875
  };
2523
- exports.updateFileV1GraphsGraphIdTablesFilesFileIdPatch = updateFileV1GraphsGraphIdTablesFilesFileIdPatch;
2876
+ exports.updateFileStatus = updateFileStatus;
2524
2877
  /**
2525
2878
  * Ingest Tables to Graph
2526
- * Load all files from S3 into DuckDB staging tables and ingest into Kuzu graph database. Use rebuild=true to regenerate the entire graph from scratch (safe operation - S3 is source of truth).
2879
+ * Load all files from S3 into DuckDB staging tables and ingest into Kuzu graph database.
2880
+ *
2881
+ * **Purpose:**
2882
+ * Orchestrates the complete data pipeline from S3 staging files into the Kuzu graph database.
2883
+ * Processes all tables in a single bulk operation with comprehensive error handling and metrics.
2884
+ *
2885
+ * **Use Cases:**
2886
+ * - Initial graph population from uploaded data
2887
+ * - Incremental data updates with new files
2888
+ * - Complete database rebuild from source files
2889
+ * - Recovery from failed ingestion attempts
2890
+ *
2891
+ * **Workflow:**
2892
+ * 1. Upload data files via `POST /tables/{table_name}/files`
2893
+ * 2. Files are validated and marked as 'uploaded'
2894
+ * 3. Trigger ingestion: `POST /tables/ingest`
2895
+ * 4. DuckDB staging tables created from S3 patterns
2896
+ * 5. Data copied row-by-row from DuckDB to Kuzu
2897
+ * 6. Per-table results and metrics returned
2898
+ *
2899
+ * **Rebuild Feature:**
2900
+ * Setting `rebuild=true` regenerates the entire graph database from scratch:
2901
+ * - Deletes existing Kuzu database
2902
+ * - Recreates with fresh schema from active GraphSchema
2903
+ * - Ingests all data files
2904
+ * - Safe operation - S3 is source of truth
2905
+ * - Useful for schema changes or data corrections
2906
+ * - Graph marked as 'rebuilding' during process
2907
+ *
2908
+ * **Error Handling:**
2909
+ * - Per-table error isolation with `ignore_errors` flag
2910
+ * - Partial success support (some tables succeed, some fail)
2911
+ * - Detailed error reporting per table
2912
+ * - Graph status tracking throughout process
2913
+ * - Automatic failure recovery and cleanup
2914
+ *
2915
+ * **Performance:**
2916
+ * - Processes all tables in sequence
2917
+ * - Each table timed independently
2918
+ * - Total execution metrics provided
2919
+ * - Scales to thousands of files
2920
+ * - Optimized for large datasets
2921
+ *
2922
+ * **Example Request:**
2923
+ * ```bash
2924
+ * curl -X POST "https://api.robosystems.ai/v1/graphs/kg123/tables/ingest" \
2925
+ * -H "Authorization: Bearer YOUR_TOKEN" \
2926
+ * -H "Content-Type: application/json" \
2927
+ * -d '{
2928
+ * "ignore_errors": true,
2929
+ * "rebuild": false
2930
+ * }'
2931
+ * ```
2932
+ *
2933
+ * **Example Response:**
2934
+ * ```json
2935
+ * {
2936
+ * "status": "success",
2937
+ * "graph_id": "kg123",
2938
+ * "total_tables": 5,
2939
+ * "successful_tables": 5,
2940
+ * "failed_tables": 0,
2941
+ * "skipped_tables": 0,
2942
+ * "total_rows_ingested": 25000,
2943
+ * "total_execution_time_ms": 15420.5,
2944
+ * "results": [
2945
+ * {
2946
+ * "table_name": "Entity",
2947
+ * "status": "success",
2948
+ * "rows_ingested": 5000,
2949
+ * "execution_time_ms": 3200.1,
2950
+ * "error": null
2951
+ * }
2952
+ * ]
2953
+ * }
2954
+ * ```
2955
+ *
2956
+ * **Concurrency Control:**
2957
+ * Only one ingestion can run per graph at a time. If another ingestion is in progress,
2958
+ * you'll receive a 409 Conflict error. The distributed lock automatically expires after
2959
+ * the configured TTL (default: 1 hour) to prevent deadlocks from failed ingestions.
2960
+ *
2961
+ * **Tips:**
2962
+ * - Only files with 'uploaded' status are processed
2963
+ * - Tables with no uploaded files are skipped
2964
+ * - Use `ignore_errors=false` for strict validation
2965
+ * - Monitor progress via per-table results
2966
+ * - Check graph metadata for rebuild status
2967
+ * - Wait for current ingestion to complete before starting another
2968
+ *
2969
+ * **Note:**
2970
+ * Table ingestion is included - no credit consumption.
2527
2971
  */
2528
- const ingestTablesV1GraphsGraphIdTablesIngestPost = (options) => {
2972
+ const ingestTables = (options) => {
2529
2973
  return (options.client ?? client_gen_1.client).post({
2530
2974
  security: [
2531
2975
  {
@@ -2545,12 +2989,70 @@ const ingestTablesV1GraphsGraphIdTablesIngestPost = (options) => {
2545
2989
  }
2546
2990
  });
2547
2991
  };
2548
- exports.ingestTablesV1GraphsGraphIdTablesIngestPost = ingestTablesV1GraphsGraphIdTablesIngestPost;
2992
+ exports.ingestTables = ingestTables;
2549
2993
  /**
2550
2994
  * Query Staging Tables with SQL
2551
- * Execute SQL queries on DuckDB staging tables
2995
+ * Execute SQL queries on DuckDB staging tables for data inspection and validation.
2996
+ *
2997
+ * **Purpose:**
2998
+ * Query raw staging data directly with SQL before ingestion into the graph database.
2999
+ * Useful for data quality checks, validation, and exploratory analysis.
3000
+ *
3001
+ * **Use Cases:**
3002
+ * - Validate data quality before graph ingestion
3003
+ * - Inspect row-level data for debugging
3004
+ * - Run analytics on staging tables
3005
+ * - Check for duplicates, nulls, or data issues
3006
+ * - Preview data transformations
3007
+ *
3008
+ * **Workflow:**
3009
+ * 1. Upload data files via `POST /tables/{table_name}/files`
3010
+ * 2. Query staging tables to validate: `POST /tables/query`
3011
+ * 3. Fix any data issues by re-uploading
3012
+ * 4. Ingest validated data: `POST /tables/ingest`
3013
+ *
3014
+ * **Supported SQL:**
3015
+ * - Full DuckDB SQL syntax
3016
+ * - SELECT, JOIN, WHERE, GROUP BY, ORDER BY
3017
+ * - Aggregations, window functions, CTEs
3018
+ * - Multiple table joins across staging area
3019
+ *
3020
+ * **Example Queries:**
3021
+ * ```sql
3022
+ * -- Count rows in staging table
3023
+ * SELECT COUNT(*) FROM Entity;
3024
+ *
3025
+ * -- Check for nulls
3026
+ * SELECT * FROM Entity WHERE name IS NULL LIMIT 10;
3027
+ *
3028
+ * -- Find duplicates
3029
+ * SELECT identifier, COUNT(*) as cnt
3030
+ * FROM Entity
3031
+ * GROUP BY identifier
3032
+ * HAVING COUNT(*) > 1;
3033
+ *
3034
+ * -- Join across tables
3035
+ * SELECT e.name, COUNT(t.id) as transaction_count
3036
+ * FROM Entity e
3037
+ * LEFT JOIN Transaction t ON e.identifier = t.entity_id
3038
+ * GROUP BY e.name
3039
+ * ORDER BY transaction_count DESC;
3040
+ * ```
3041
+ *
3042
+ * **Limits:**
3043
+ * - Query timeout: 30 seconds
3044
+ * - Result limit: 10,000 rows (use LIMIT clause)
3045
+ * - Read-only: No INSERT, UPDATE, DELETE
3046
+ * - User's tables only: Cannot query other users' data
3047
+ *
3048
+ * **Shared Repositories:**
3049
+ * Shared repositories (SEC, etc.) do not allow direct SQL queries.
3050
+ * Use the graph query endpoint instead: `POST /v1/graphs/{graph_id}/query`
3051
+ *
3052
+ * **Note:**
3053
+ * Staging table queries are included - no credit consumption.
2552
3054
  */
2553
- const queryTablesV1GraphsGraphIdTablesQueryPost = (options) => {
3055
+ const queryTables = (options) => {
2554
3056
  return (options.client ?? client_gen_1.client).post({
2555
3057
  security: [
2556
3058
  {
@@ -2570,7 +3072,7 @@ const queryTablesV1GraphsGraphIdTablesQueryPost = (options) => {
2570
3072
  }
2571
3073
  });
2572
3074
  };
2573
- exports.queryTablesV1GraphsGraphIdTablesQueryPost = queryTablesV1GraphsGraphIdTablesQueryPost;
3075
+ exports.queryTables = queryTables;
2574
3076
  /**
2575
3077
  * Get User Graphs
2576
3078
  * Get all graph databases accessible to the current user.