@vaiftech/client 1.0.4 → 1.0.5

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/dist/index.d.mts CHANGED
@@ -2628,6 +2628,12 @@ interface Environment {
2628
2628
  id: string;
2629
2629
  projectId: string;
2630
2630
  name: string;
2631
+ type?: string;
2632
+ url?: string;
2633
+ customDomain?: string | null;
2634
+ customDomainVerified?: boolean;
2635
+ isActive?: boolean;
2636
+ config?: Record<string, unknown>;
2631
2637
  createdAt: string;
2632
2638
  updatedAt: string;
2633
2639
  }
@@ -4103,6 +4109,7 @@ interface CheckEntitlementResponse {
4103
4109
  interface CheckoutInput {
4104
4110
  orgId: string;
4105
4111
  plan: "starter" | "pro" | "agency" | "studio_plus";
4112
+ interval?: "monthly" | "yearly";
4106
4113
  successUrl?: string;
4107
4114
  cancelUrl?: string;
4108
4115
  }
@@ -4112,6 +4119,19 @@ interface CheckoutInput {
4112
4119
  interface CheckoutResponse {
4113
4120
  url: string;
4114
4121
  }
4122
+ /**
4123
+ * Checkout session verification response
4124
+ */
4125
+ interface CheckoutVerifyResponse {
4126
+ ok: boolean;
4127
+ status: "complete" | "expired" | "open";
4128
+ paymentStatus: "paid" | "unpaid" | "no_payment_required";
4129
+ plan: string;
4130
+ interval: string;
4131
+ subscriptionId: string | null;
4132
+ subscriptionStatus: string | null;
4133
+ currentPeriodEnd: string | null;
4134
+ }
4115
4135
  /**
4116
4136
  * Portal input
4117
4137
  */
@@ -4274,6 +4294,10 @@ interface BillingModule {
4274
4294
  * Create a Stripe checkout session for upgrading
4275
4295
  */
4276
4296
  createCheckout(input: CheckoutInput): Promise<CheckoutResponse>;
4297
+ /**
4298
+ * Verify a checkout session after redirect (call this on billing page load with session_id param)
4299
+ */
4300
+ verifyCheckoutSession(sessionId: string): Promise<CheckoutVerifyResponse>;
4277
4301
  /**
4278
4302
  * Open Stripe billing portal for managing subscription
4279
4303
  */
@@ -4669,6 +4693,43 @@ interface DLQListOptions {
4669
4693
  limit?: number;
4670
4694
  offset?: number;
4671
4695
  }
4696
+ /**
4697
+ * Feature flag
4698
+ */
4699
+ interface FeatureFlag$1 {
4700
+ id: string;
4701
+ key: string;
4702
+ enabled: boolean;
4703
+ createdAt: string;
4704
+ updatedAt: string;
4705
+ }
4706
+ /**
4707
+ * Admin user (super admin)
4708
+ */
4709
+ interface SuperAdmin {
4710
+ id: string;
4711
+ userId: string;
4712
+ role: string;
4713
+ permissions: string[];
4714
+ notes: string | null;
4715
+ isActive: boolean;
4716
+ lastAccessAt: string | null;
4717
+ createdAt: string;
4718
+ updatedAt: string;
4719
+ email?: string;
4720
+ name?: string;
4721
+ }
4722
+ /**
4723
+ * System setting
4724
+ */
4725
+ interface SystemSetting {
4726
+ key: string;
4727
+ value: unknown;
4728
+ category: string;
4729
+ description: string | null;
4730
+ isSecret: boolean;
4731
+ updatedAt: string | null;
4732
+ }
4672
4733
  /**
4673
4734
  * Admin module interface
4674
4735
  */
@@ -4767,6 +4828,41 @@ interface AdminModule {
4767
4828
  ok: boolean;
4768
4829
  messageId: string;
4769
4830
  }>;
4831
+ listFeatureFlags(): Promise<FeatureFlag$1[]>;
4832
+ createFeatureFlag(key: string, enabled: boolean): Promise<{
4833
+ ok: boolean;
4834
+ }>;
4835
+ updateFeatureFlag(key: string, enabled: boolean): Promise<{
4836
+ ok: boolean;
4837
+ }>;
4838
+ deleteFeatureFlag(key: string): Promise<{
4839
+ ok: boolean;
4840
+ key: string;
4841
+ }>;
4842
+ listAdmins(): Promise<SuperAdmin[]>;
4843
+ addAdmin(userId: string, role?: string, notes?: string): Promise<{
4844
+ ok: boolean;
4845
+ admin: SuperAdmin;
4846
+ }>;
4847
+ updateAdmin(adminId: string, data: {
4848
+ role?: string;
4849
+ permissions?: string[];
4850
+ isActive?: boolean;
4851
+ notes?: string;
4852
+ }): Promise<{
4853
+ ok: boolean;
4854
+ }>;
4855
+ removeAdmin(adminId: string): Promise<{
4856
+ ok: boolean;
4857
+ }>;
4858
+ getSettings(category?: string): Promise<{
4859
+ settings: Record<string, SystemSetting[]>;
4860
+ total: number;
4861
+ }>;
4862
+ updateSetting(key: string, value: unknown): Promise<{
4863
+ ok: boolean;
4864
+ key: string;
4865
+ }>;
4770
4866
  }
4771
4867
 
4772
4868
  /**
@@ -5184,6 +5280,348 @@ interface BudgetStatus {
5184
5280
  hardStop: boolean;
5185
5281
  percentUsed: number;
5186
5282
  }
5283
+ /**
5284
+ * AI model tiers
5285
+ */
5286
+ type AIModelTier = "free" | "paid" | "enterprise";
5287
+ /**
5288
+ * AI model provider
5289
+ */
5290
+ type AIModelProvider = "openai" | "anthropic";
5291
+ /**
5292
+ * Generation types supported by the AI workspace
5293
+ */
5294
+ type GenerationType = "schema" | "storage" | "functions" | "backend" | "fullstack";
5295
+ /**
5296
+ * Model capabilities
5297
+ */
5298
+ interface AIModelCapabilities {
5299
+ streaming: boolean;
5300
+ vision: boolean;
5301
+ toolUse: boolean;
5302
+ reasoning: boolean;
5303
+ codeGeneration: boolean;
5304
+ }
5305
+ /**
5306
+ * An AI model available in the platform
5307
+ */
5308
+ interface AIModel {
5309
+ id: string;
5310
+ provider: AIModelProvider;
5311
+ displayName: string;
5312
+ description: string;
5313
+ tier: AIModelTier;
5314
+ creditMultiplier: number;
5315
+ maxInputTokens: number;
5316
+ maxOutputTokens: number;
5317
+ capabilities: AIModelCapabilities;
5318
+ bestFor: string[];
5319
+ }
5320
+ /**
5321
+ * Available models response
5322
+ */
5323
+ interface AvailableModelsResult {
5324
+ models: AIModel[];
5325
+ recommended: {
5326
+ primary: string;
5327
+ reasoning: string;
5328
+ quick: string;
5329
+ };
5330
+ plan: string;
5331
+ modelTier: AIModelTier;
5332
+ maxContextTokens: number;
5333
+ }
5334
+ /**
5335
+ * Workspace session types
5336
+ */
5337
+ type WorkspaceSessionType = "backend_generation" | "schema_design" | "code_review";
5338
+ /**
5339
+ * Workspace session status
5340
+ */
5341
+ type WorkspaceSessionStatus = "active" | "completed" | "error" | "cancelled";
5342
+ /**
5343
+ * Turn types in a workspace session
5344
+ */
5345
+ type WorkspaceTurnType = "user_input" | "clarification" | "reasoning" | "generation";
5346
+ /**
5347
+ * A turn in a workspace session
5348
+ */
5349
+ interface WorkspaceTurn {
5350
+ id: string;
5351
+ sessionId: string;
5352
+ turnIndex: number;
5353
+ turnType: WorkspaceTurnType;
5354
+ inputContent?: string;
5355
+ reasoningContent?: string;
5356
+ outputContent?: string;
5357
+ generatedCode?: Record<string, string>;
5358
+ clarificationQuestions?: ClarificationQuestion[];
5359
+ clarificationResponses?: ClarificationResponses;
5360
+ inputTokens: number;
5361
+ outputTokens: number;
5362
+ creditsCharged: string;
5363
+ modelUsed?: string;
5364
+ durationMs?: number;
5365
+ status: string;
5366
+ createdAt: string;
5367
+ }
5368
+ /**
5369
+ * A workspace session
5370
+ */
5371
+ interface WorkspaceSession {
5372
+ id: string;
5373
+ projectId: string;
5374
+ userId: string;
5375
+ sessionType: WorkspaceSessionType;
5376
+ title?: string;
5377
+ description?: string;
5378
+ status: WorkspaceSessionStatus;
5379
+ generationConfig: Record<string, unknown>;
5380
+ contextSnapshot: ProjectContext;
5381
+ primaryModelId?: string;
5382
+ totalInputTokens: number;
5383
+ totalOutputTokens: number;
5384
+ totalCreditsUsed: string;
5385
+ outputArtifacts: Array<{
5386
+ type: string;
5387
+ id: string;
5388
+ }>;
5389
+ createdAt: string;
5390
+ updatedAt: string;
5391
+ completedAt?: string;
5392
+ }
5393
+ /**
5394
+ * Input for creating a workspace session
5395
+ */
5396
+ interface CreateWorkspaceSessionInput {
5397
+ projectId: string;
5398
+ sessionType: WorkspaceSessionType;
5399
+ title?: string;
5400
+ description?: string;
5401
+ primaryModelId?: string;
5402
+ generationConfig?: {
5403
+ framework?: "express" | "fastify" | "hono";
5404
+ language?: "typescript" | "javascript";
5405
+ packageManager?: "npm" | "yarn" | "pnpm" | "bun";
5406
+ };
5407
+ }
5408
+ /**
5409
+ * Input for submitting a prompt
5410
+ */
5411
+ interface SubmitPromptInput {
5412
+ prompt: string;
5413
+ modelId?: string;
5414
+ }
5415
+ /**
5416
+ * Clarification question types
5417
+ */
5418
+ type ClarificationQuestionType = "multiple_choice" | "text" | "boolean" | "multi_select";
5419
+ /**
5420
+ * Clarification categories
5421
+ */
5422
+ type ClarificationCategory = "architecture" | "features" | "data_model" | "auth" | "api_design" | "storage" | "realtime" | "deployment" | "integrations";
5423
+ /**
5424
+ * A clarification question
5425
+ */
5426
+ interface ClarificationQuestion {
5427
+ id: string;
5428
+ question: string;
5429
+ type: ClarificationQuestionType;
5430
+ category: ClarificationCategory;
5431
+ options?: string[];
5432
+ defaultValue?: string | string[];
5433
+ required: boolean;
5434
+ helpText?: string;
5435
+ }
5436
+ /**
5437
+ * User's responses to clarification questions
5438
+ */
5439
+ interface ClarificationResponses {
5440
+ [questionId: string]: string | string[] | boolean;
5441
+ }
5442
+ /**
5443
+ * Extracted requirements from a prompt
5444
+ */
5445
+ interface ExtractedRequirements {
5446
+ projectType?: string;
5447
+ features: string[];
5448
+ dataEntities: string[];
5449
+ authMethod?: string;
5450
+ apiStyle?: string;
5451
+ frameworks?: string[];
5452
+ integrations: string[];
5453
+ unclear: string[];
5454
+ }
5455
+ /**
5456
+ * Clarification analysis result
5457
+ */
5458
+ interface ClarificationAnalysisResult {
5459
+ needsClarification: boolean;
5460
+ confidence: "low" | "medium" | "high";
5461
+ questions: ClarificationQuestion[];
5462
+ extractedRequirements: ExtractedRequirements;
5463
+ suggestedApproach?: string;
5464
+ }
5465
+ /**
5466
+ * Submit prompt result
5467
+ */
5468
+ interface SubmitPromptResult {
5469
+ turn: WorkspaceTurn;
5470
+ needsClarification: boolean;
5471
+ questions: ClarificationQuestion[];
5472
+ suggestedApproach?: string;
5473
+ extractedRequirements: ExtractedRequirements;
5474
+ }
5475
+ /**
5476
+ * Submit clarification result
5477
+ */
5478
+ interface SubmitClarificationResult {
5479
+ turn: WorkspaceTurn;
5480
+ config: BackendGenerationConfig;
5481
+ readyToGenerate: boolean;
5482
+ }
5483
+ /**
5484
+ * Backend generation configuration
5485
+ */
5486
+ interface BackendGenerationConfig {
5487
+ framework: "express" | "fastify" | "hono";
5488
+ language: "typescript" | "javascript";
5489
+ packageManager: "npm" | "yarn" | "pnpm" | "bun";
5490
+ authMethod: "none" | "jwt" | "session" | "oauth" | "api_key";
5491
+ apiStyle: "rest" | "graphql" | "trpc";
5492
+ includeRealtime: boolean;
5493
+ features: {
5494
+ validation: boolean;
5495
+ errorHandling: boolean;
5496
+ logging: boolean;
5497
+ cors: boolean;
5498
+ rateLimit: boolean;
5499
+ tests: boolean;
5500
+ docker: boolean;
5501
+ };
5502
+ }
5503
+ /**
5504
+ * A generated backend
5505
+ */
5506
+ interface GeneratedBackend {
5507
+ id: string;
5508
+ projectId: string;
5509
+ sessionId?: string;
5510
+ userId: string;
5511
+ name: string;
5512
+ description?: string;
5513
+ framework: string;
5514
+ language: string;
5515
+ packageManager: string;
5516
+ files: Record<string, string>;
5517
+ fileCount: number;
5518
+ totalLines: number;
5519
+ connectionConfig: Record<string, unknown>;
5520
+ dependencies: Record<string, string>;
5521
+ devDependencies: Record<string, string>;
5522
+ status: "draft" | "ready" | "deployed";
5523
+ githubRepoUrl?: string;
5524
+ deployedUrl?: string;
5525
+ createdAt: string;
5526
+ updatedAt: string;
5527
+ }
5528
+ /**
5529
+ * Generate backend result
5530
+ */
5531
+ interface GenerateBackendResult {
5532
+ backend: GeneratedBackend;
5533
+ files: Array<{
5534
+ path: string;
5535
+ content: string;
5536
+ language: string;
5537
+ }>;
5538
+ totalLines: number;
5539
+ }
5540
+ /**
5541
+ * Input for generating a backend
5542
+ */
5543
+ interface GenerateBackendInput {
5544
+ name: string;
5545
+ config?: Partial<BackendGenerationConfig>;
5546
+ }
5547
+ /**
5548
+ * Project context for AI operations
5549
+ */
5550
+ interface ProjectContext {
5551
+ project: {
5552
+ id: string;
5553
+ name: string;
5554
+ slug: string;
5555
+ features: Record<string, boolean>;
5556
+ };
5557
+ schema: {
5558
+ tables: Array<{
5559
+ name: string;
5560
+ columns: Array<{
5561
+ name: string;
5562
+ type: string;
5563
+ nullable: boolean;
5564
+ }>;
5565
+ primaryKey: string[];
5566
+ foreignKeys: Array<{
5567
+ columns: string[];
5568
+ referencesTable: string;
5569
+ referencesColumns: string[];
5570
+ }>;
5571
+ }>;
5572
+ totalRelationships: number;
5573
+ };
5574
+ storage: {
5575
+ buckets: Array<{
5576
+ name: string;
5577
+ public: boolean;
5578
+ size?: number;
5579
+ }>;
5580
+ };
5581
+ functions: {
5582
+ list: Array<{
5583
+ name: string;
5584
+ description?: string;
5585
+ }>;
5586
+ totalFunctions: number;
5587
+ };
5588
+ tokenCounts: {
5589
+ schema: number;
5590
+ storage: number;
5591
+ functions: number;
5592
+ code: number;
5593
+ total: number;
5594
+ };
5595
+ }
5596
+ /**
5597
+ * Context summary
5598
+ */
5599
+ interface ContextSummary {
5600
+ tables: number;
5601
+ columns: number;
5602
+ relationships: number;
5603
+ buckets: number;
5604
+ functions: number;
5605
+ tokens: number;
5606
+ }
5607
+ /**
5608
+ * Get context result
5609
+ */
5610
+ interface GetContextResult {
5611
+ context: ProjectContext;
5612
+ summary: ContextSummary;
5613
+ formatted: string;
5614
+ tokenCounts: ProjectContext["tokenCounts"];
5615
+ }
5616
+ /**
5617
+ * Token estimation result
5618
+ */
5619
+ interface EstimateTokensResult {
5620
+ promptTokens: number;
5621
+ contextTokens: number;
5622
+ totalTokens: number;
5623
+ estimatedCost: number;
5624
+ }
5187
5625
  /**
5188
5626
  * AI module interface for the VAIF client
5189
5627
  */
@@ -5308,6 +5746,153 @@ interface AIModule {
5308
5746
  deleteConversation(conversationId: string): Promise<{
5309
5747
  ok: boolean;
5310
5748
  }>;
5749
+ /**
5750
+ * Get available AI models for the current user's plan
5751
+ *
5752
+ * @example
5753
+ * ```ts
5754
+ * const result = await vaif.ai.getAvailableModels();
5755
+ * console.log(result.models); // Available models
5756
+ * console.log(result.recommended); // Recommended models for different tasks
5757
+ * ```
5758
+ */
5759
+ getAvailableModels(): Promise<AvailableModelsResult>;
5760
+ /**
5761
+ * Get details for a specific model
5762
+ */
5763
+ getModel(modelId: string): Promise<{
5764
+ model: AIModel;
5765
+ }>;
5766
+ /**
5767
+ * Get full project context for AI operations
5768
+ *
5769
+ * @example
5770
+ * ```ts
5771
+ * const result = await vaif.ai.getProjectContext('proj_123');
5772
+ * console.log(result.summary); // { tables: 5, columns: 25, ... }
5773
+ * console.log(result.tokenCounts.total); // Total tokens used for context
5774
+ * ```
5775
+ */
5776
+ getProjectContext(projectId: string): Promise<GetContextResult>;
5777
+ /**
5778
+ * Estimate tokens for a prompt
5779
+ */
5780
+ estimateTokens(prompt: string, projectId?: string): Promise<EstimateTokensResult>;
5781
+ /**
5782
+ * Analyze a prompt and get clarification questions before generation
5783
+ *
5784
+ * @example
5785
+ * ```ts
5786
+ * const result = await vaif.ai.analyzeForClarification({
5787
+ * prompt: 'Create a chat application backend',
5788
+ * projectId: 'proj_123'
5789
+ * });
5790
+ * if (result.needsClarification) {
5791
+ * console.log(result.questions); // Questions to ask user
5792
+ * }
5793
+ * ```
5794
+ */
5795
+ analyzeForClarification(input: {
5796
+ prompt: string;
5797
+ projectId: string;
5798
+ }): Promise<ClarificationAnalysisResult>;
5799
+ /**
5800
+ * Get AI-generated prompt suggestions based on generation types
5801
+ *
5802
+ * @example
5803
+ * ```ts
5804
+ * const result = await vaif.ai.getSuggestions({
5805
+ * projectId: 'proj_123',
5806
+ * generationTypes: ['schema', 'backend']
5807
+ * });
5808
+ * console.log(result.suggestions); // Array of contextual prompt suggestions
5809
+ * ```
5810
+ */
5811
+ getSuggestions(input: {
5812
+ projectId: string;
5813
+ generationTypes: GenerationType[];
5814
+ }): Promise<{
5815
+ suggestions: string[];
5816
+ }>;
5817
+ /**
5818
+ * Create a new AI workspace session
5819
+ *
5820
+ * @example
5821
+ * ```ts
5822
+ * const result = await vaif.ai.workspace.create({
5823
+ * projectId: 'proj_123',
5824
+ * sessionType: 'backend_generation',
5825
+ * title: 'Chat App Backend'
5826
+ * });
5827
+ * console.log(result.session.id);
5828
+ * ```
5829
+ */
5830
+ workspace: {
5831
+ /**
5832
+ * Create a new workspace session
5833
+ */
5834
+ create(input: CreateWorkspaceSessionInput): Promise<{
5835
+ session: WorkspaceSession;
5836
+ }>;
5837
+ /**
5838
+ * Get a workspace session with its turns
5839
+ */
5840
+ get(sessionId: string): Promise<{
5841
+ session: WorkspaceSession;
5842
+ turns: WorkspaceTurn[];
5843
+ }>;
5844
+ /**
5845
+ * List workspace sessions for a project
5846
+ */
5847
+ list(projectId: string): Promise<{
5848
+ sessions: WorkspaceSession[];
5849
+ }>;
5850
+ /**
5851
+ * Submit a prompt to a workspace session
5852
+ */
5853
+ submitPrompt(sessionId: string, input: SubmitPromptInput): Promise<SubmitPromptResult>;
5854
+ /**
5855
+ * Submit clarification responses
5856
+ */
5857
+ submitClarification(sessionId: string, responses: ClarificationResponses): Promise<SubmitClarificationResult>;
5858
+ /**
5859
+ * Generate backend code for a session
5860
+ */
5861
+ generate(sessionId: string, input: GenerateBackendInput): Promise<GenerateBackendResult>;
5862
+ };
5863
+ /**
5864
+ * Generated backend operations
5865
+ */
5866
+ backends: {
5867
+ /**
5868
+ * Get a generated backend by ID
5869
+ */
5870
+ get(backendId: string): Promise<{
5871
+ backend: GeneratedBackend;
5872
+ }>;
5873
+ /**
5874
+ * List generated backends for a project
5875
+ */
5876
+ list(projectId: string): Promise<{
5877
+ backends: Array<{
5878
+ id: string;
5879
+ name: string;
5880
+ description?: string;
5881
+ framework: string;
5882
+ language: string;
5883
+ fileCount: number;
5884
+ totalLines: number;
5885
+ status: string;
5886
+ createdAt: string;
5887
+ }>;
5888
+ }>;
5889
+ /**
5890
+ * Delete a generated backend
5891
+ */
5892
+ delete(backendId: string): Promise<{
5893
+ ok: boolean;
5894
+ }>;
5895
+ };
5311
5896
  }
5312
5897
 
5313
5898
  /**