@useago/sdk 0.4.2 → 0.4.4

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/react.d.cts CHANGED
@@ -542,6 +542,14 @@ export declare interface CreateFormCollectorOptions<V = Record<string, unknown>>
542
542
  */
543
543
  export declare function createMockClient(options?: MockAgoClientOptions): MockAgoClient;
544
544
 
545
+ /**
546
+ * Compute which required fields are still empty and whether the form is complete.
547
+ * Pure — the single home for the "required + non-empty" rule, shared by the update
548
+ * handler, submit, the dynamic context, and the React hook. Derived on read so the
549
+ * store only ever holds canonical state ({@link FormCollectorState}).
550
+ */
551
+ export declare function deriveFormStatus(schema: FormCollectorSchema, values: Partial<Record<string, unknown>>): FormCollectorStatus;
552
+
545
553
  /**
546
554
  * A function that returns a fresh context entry on demand.
547
555
  * Evaluated every time a message is sent — use it to pull data from stores,
@@ -583,16 +591,20 @@ export declare interface FormCollector<V = Record<string, unknown>> {
583
591
  */
584
592
  export declare type FormCollectorSchema = ClientFunctionSchema["parameters"];
585
593
 
586
- /** Live state held in the collector's store. */
594
+ /** Canonical, source-of-truth state held in the collector's store. */
587
595
  export declare interface FormCollectorState<V = Record<string, unknown>> {
588
596
  /** Field values collected so far. */
589
597
  values: Partial<V>;
598
+ /** True once a submit succeeded. */
599
+ submitted: boolean;
600
+ }
601
+
602
+ /** Completeness status derived from values + schema — computed on read, never stored. */
603
+ export declare interface FormCollectorStatus {
590
604
  /** Required field names still empty. */
591
605
  missing: string[];
592
606
  /** True when no required field is missing. */
593
607
  complete: boolean;
594
- /** True once a submit succeeded. */
595
- submitted: boolean;
596
608
  }
597
609
 
598
610
  declare interface FormField {
@@ -994,8 +1006,11 @@ export declare interface UseConversationResult {
994
1006
  export declare function useFormCollector<V = Record<string, unknown>>(options: CreateFormCollectorOptions<V>): UseFormCollectorResult<V>;
995
1007
 
996
1008
  export declare interface UseFormCollectorResult<V = Record<string, unknown>> extends FormCollector<V> {
997
- /** Live form state from the collector's store — re-renders on every change. */
998
- state: FormCollectorState<V>;
1009
+ /**
1010
+ * Live form state from the store (`values`, `submitted`) plus the completeness
1011
+ * status (`missing`, `complete`) derived on read — re-renders on every change.
1012
+ */
1013
+ state: FormCollectorState<V> & FormCollectorStatus;
999
1014
  }
1000
1015
 
1001
1016
  /**
package/dist/react.d.ts CHANGED
@@ -542,6 +542,14 @@ export declare interface CreateFormCollectorOptions<V = Record<string, unknown>>
542
542
  */
543
543
  export declare function createMockClient(options?: MockAgoClientOptions): MockAgoClient;
544
544
 
545
+ /**
546
+ * Compute which required fields are still empty and whether the form is complete.
547
+ * Pure — the single home for the "required + non-empty" rule, shared by the update
548
+ * handler, submit, the dynamic context, and the React hook. Derived on read so the
549
+ * store only ever holds canonical state ({@link FormCollectorState}).
550
+ */
551
+ export declare function deriveFormStatus(schema: FormCollectorSchema, values: Partial<Record<string, unknown>>): FormCollectorStatus;
552
+
545
553
  /**
546
554
  * A function that returns a fresh context entry on demand.
547
555
  * Evaluated every time a message is sent — use it to pull data from stores,
@@ -583,16 +591,20 @@ export declare interface FormCollector<V = Record<string, unknown>> {
583
591
  */
584
592
  export declare type FormCollectorSchema = ClientFunctionSchema["parameters"];
585
593
 
586
- /** Live state held in the collector's store. */
594
+ /** Canonical, source-of-truth state held in the collector's store. */
587
595
  export declare interface FormCollectorState<V = Record<string, unknown>> {
588
596
  /** Field values collected so far. */
589
597
  values: Partial<V>;
598
+ /** True once a submit succeeded. */
599
+ submitted: boolean;
600
+ }
601
+
602
+ /** Completeness status derived from values + schema — computed on read, never stored. */
603
+ export declare interface FormCollectorStatus {
590
604
  /** Required field names still empty. */
591
605
  missing: string[];
592
606
  /** True when no required field is missing. */
593
607
  complete: boolean;
594
- /** True once a submit succeeded. */
595
- submitted: boolean;
596
608
  }
597
609
 
598
610
  declare interface FormField {
@@ -994,8 +1006,11 @@ export declare interface UseConversationResult {
994
1006
  export declare function useFormCollector<V = Record<string, unknown>>(options: CreateFormCollectorOptions<V>): UseFormCollectorResult<V>;
995
1007
 
996
1008
  export declare interface UseFormCollectorResult<V = Record<string, unknown>> extends FormCollector<V> {
997
- /** Live form state from the collector's store — re-renders on every change. */
998
- state: FormCollectorState<V>;
1009
+ /**
1010
+ * Live form state from the store (`values`, `submitted`) plus the completeness
1011
+ * status (`missing`, `complete`) derived on read — re-renders on every change.
1012
+ */
1013
+ state: FormCollectorState<V> & FormCollectorStatus;
999
1014
  }
1000
1015
 
1001
1016
  /**