@mindstudio-ai/agent 0.1.35 → 0.1.37

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.ts CHANGED
@@ -223,8 +223,8 @@ interface AppRoleAssignment {
223
223
  }
224
224
  /** Auth context for an app. */
225
225
  interface AppAuthContext {
226
- /** The authenticated user ID. */
227
- userId: string;
226
+ /** The authenticated user ID, or null for unauthenticated users. */
227
+ userId: string | null;
228
228
  /** All role assignments for this app (all users, all roles). */
229
229
  roleAssignments: AppRoleAssignment[];
230
230
  }
@@ -477,8 +477,8 @@ interface HttpClientConfig {
477
477
  * context hydration time.
478
478
  */
479
479
  declare class AuthContext {
480
- /** The current user's ID. */
481
- readonly userId: string;
480
+ /** The current user's ID, or null for unauthenticated users. */
481
+ readonly userId: string | null;
482
482
  /** The current user's roles in this app. */
483
483
  readonly roles: readonly string[];
484
484
  /** All role assignments for this app (all users, all roles). */
@@ -725,19 +725,27 @@ interface SqlResult {
725
725
  * performance optimization.
726
726
  */
727
727
 
728
- declare class Query<T> implements PromiseLike<T[]> {
728
+ declare class Query<T, TResult = T[]> implements PromiseLike<TResult> {
729
729
  private readonly _predicates;
730
730
  private readonly _sortAccessor;
731
731
  private readonly _reversed;
732
732
  private readonly _limit;
733
733
  private readonly _offset;
734
734
  private readonly _config;
735
+ /** @internal Pre-compiled WHERE clause (bypasses predicate compiler). Used by Table.get(). */
736
+ private readonly _rawWhere;
737
+ private readonly _rawWhereParams;
738
+ /** @internal Post-process transform applied after row deserialization. */
739
+ readonly _postProcess: ((rows: T[]) => TResult) | undefined;
735
740
  constructor(config: TableConfig, options?: {
736
741
  predicates?: Predicate<T>[];
737
742
  sortAccessor?: Accessor<T>;
738
743
  reversed?: boolean;
739
744
  limit?: number;
740
745
  offset?: number;
746
+ postProcess?: (rows: T[]) => TResult;
747
+ rawWhere?: string;
748
+ rawWhereParams?: unknown[];
741
749
  });
742
750
  private _clone;
743
751
  filter(predicate: Predicate<T>): Query<T>;
@@ -745,14 +753,14 @@ declare class Query<T> implements PromiseLike<T[]> {
745
753
  reverse(): Query<T>;
746
754
  take(n: number): Query<T>;
747
755
  skip(n: number): Query<T>;
748
- first(): Promise<T | null>;
749
- last(): Promise<T | null>;
750
- count(): Promise<number>;
751
- some(): Promise<boolean>;
756
+ first(): Query<T, T | null>;
757
+ last(): Query<T, T | null>;
758
+ count(): Query<T, number>;
759
+ some(): Query<T, boolean>;
752
760
  every(): Promise<boolean>;
753
- min(accessor: Accessor<T, number>): Promise<T | null>;
754
- max(accessor: Accessor<T, number>): Promise<T | null>;
755
- groupBy<K extends string | number>(accessor: Accessor<T, K>): Promise<Map<K, T[]>>;
761
+ min(accessor: Accessor<T, number>): Query<T, T | null>;
762
+ max(accessor: Accessor<T, number>): Query<T, T | null>;
763
+ groupBy<K extends string | number>(accessor: Accessor<T, K>): Query<T, Map<K, T[]>>;
756
764
  /**
757
765
  * @internal Compile this query into a SqlQuery for batch execution.
758
766
  *
@@ -761,7 +769,7 @@ declare class Query<T> implements PromiseLike<T[]> {
761
769
  * `SELECT *` is returned as `fallbackQuery` so the batch can fetch
762
770
  * all rows and this query can filter them in JS post-fetch.
763
771
  */
764
- _compile(): CompiledQuery<T>;
772
+ _compile(): CompiledQuery<T, TResult>;
765
773
  /**
766
774
  * @internal Process raw SQL results into typed rows. Used by db.batch()
767
775
  * after executing the compiled query.
@@ -769,9 +777,9 @@ declare class Query<T> implements PromiseLike<T[]> {
769
777
  * For SQL-compiled queries: just deserialize the rows.
770
778
  * For JS-fallback queries: filter, sort, and slice in JS.
771
779
  */
772
- static _processResults<T>(result: SqlResult, compiled: CompiledQuery<T>): T[];
773
- then<TResult1 = T[], TResult2 = never>(onfulfilled?: ((value: T[]) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
774
- catch<TResult2 = never>(onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<T[] | TResult2>;
780
+ static _processResults<T, R = T[]>(result: SqlResult, compiled: CompiledQuery<T, R>): R;
781
+ then<TResult1 = TResult, TResult2 = never>(onfulfilled?: ((value: TResult) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
782
+ catch<TResult2 = never>(onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult | TResult2>;
775
783
  private _execute;
776
784
  private _compilePredicates;
777
785
  private _fetchAndFilterInJs;
@@ -781,7 +789,7 @@ declare class Query<T> implements PromiseLike<T[]> {
781
789
  * Result of Query._compile(). Contains either a compiled SQL query
782
790
  * (fast path) or a fallback SELECT * with JS processing metadata.
783
791
  */
784
- interface CompiledQuery<T> {
792
+ interface CompiledQuery<T, TResult = T[]> {
785
793
  type: 'query';
786
794
  /** Compiled SQL query, or null if JS fallback needed. */
787
795
  query: SqlQuery | null;
@@ -799,6 +807,8 @@ interface CompiledQuery<T> {
799
807
  limit?: number;
800
808
  /** Offset (only for fallback). */
801
809
  offset?: number;
810
+ /** Post-process transform (e.g. first() extracts [0] ?? null). */
811
+ postProcess?: (rows: T[]) => TResult;
802
812
  }
803
813
 
804
814
  /**
@@ -885,16 +895,30 @@ declare class Table<T> {
885
895
  /** @internal */
886
896
  private readonly _config;
887
897
  constructor(config: TableConfig);
888
- get(id: string): Promise<T | null>;
889
- findOne(predicate: Predicate<T>): Promise<T | null>;
890
- count(predicate?: Predicate<T>): Promise<number>;
891
- some(predicate: Predicate<T>): Promise<boolean>;
898
+ /** Get a single row by ID. Returns null if not found. */
899
+ get(id: string): Query<T, T | null>;
900
+ /** Find the first row matching a predicate. Returns null if none match. */
901
+ findOne(predicate: Predicate<T>): Query<T, T | null>;
902
+ /** Count all rows, or rows matching a predicate. */
903
+ count(): Query<T, number>;
904
+ count(predicate: Predicate<T>): Query<T, number>;
905
+ /** True if any row matches the predicate. */
906
+ some(predicate: Predicate<T>): Query<T, boolean>;
907
+ /** True if all rows match the predicate. */
892
908
  every(predicate: Predicate<T>): Promise<boolean>;
909
+ /** True if the table has zero rows. */
893
910
  isEmpty(): Promise<boolean>;
894
- min(accessor: Accessor<T, number>): Promise<T | null>;
895
- max(accessor: Accessor<T, number>): Promise<T | null>;
896
- groupBy<K extends string | number>(accessor: Accessor<T, K>): Promise<Map<K, T[]>>;
911
+ /** Row with the minimum value for a field, or null if table is empty. */
912
+ min(accessor: Accessor<T, number>): Query<T, T | null>;
913
+ /** Row with the maximum value for a field, or null if table is empty. */
914
+ max(accessor: Accessor<T, number>): Query<T, T | null>;
915
+ /** Group rows by a field. Returns a Map. */
916
+ groupBy<K extends string | number>(accessor: Accessor<T, K>): Query<T, Map<K, T[]>>;
917
+ /** Get all rows as an array. */
918
+ toArray(): Query<T>;
919
+ /** Filter rows by a predicate. Returns a chainable Query. */
897
920
  filter(predicate: Predicate<T>): Query<T>;
921
+ /** Sort rows by a field. Returns a chainable Query. */
898
922
  sortBy(accessor: Accessor<T>): Query<T>;
899
923
  /**
900
924
  * Insert one or more rows. Returns the created row(s) with system fields
@@ -910,12 +934,14 @@ declare class Table<T> {
910
934
  * Returns the updated row via `UPDATE ... RETURNING *`.
911
935
  */
912
936
  update(id: string, data: UpdateInput<T>): Mutation<T>;
913
- remove(id: string): Mutation<void>;
937
+ remove(id: string): Mutation<{
938
+ deleted: boolean;
939
+ }>;
914
940
  /**
915
941
  * Remove all rows matching a predicate. Returns the count removed.
916
942
  */
917
943
  removeAll(predicate: Predicate<T>): Mutation<number>;
918
- clear(): Mutation<void>;
944
+ clear(): Mutation<number>;
919
945
  /**
920
946
  * Insert a row, or update it if a row with the same unique key already
921
947
  * exists. The conflict key must match a `unique` constraint declared in
@@ -4447,6 +4473,8 @@ interface SendEmailStepInput {
4447
4473
  subject: string;
4448
4474
  /** Email body content (plain text, markdown, HTML, or a CDN URL to an HTML file) */
4449
4475
  body: string;
4476
+ /** Direct recipient email address(es). For v2 apps, must be verified app users. */
4477
+ to?: string | string[];
4450
4478
  /** OAuth connection ID(s) for the recipient(s), comma-separated for multiple */
4451
4479
  connectionId?: string;
4452
4480
  /** When true, auto-convert the body text into a styled HTML email using AI */
@@ -7377,10 +7405,11 @@ interface StepMethods {
7377
7405
  */
7378
7406
  searchYoutubeTrends(step: SearchYoutubeTrendsStepInput, options?: StepExecutionOptions): Promise<StepExecutionResult<SearchYoutubeTrendsStepOutput>>;
7379
7407
  /**
7380
- * Send an email to one or more configured recipient addresses.
7408
+ * Send an email to one or more recipient addresses.
7381
7409
  *
7382
7410
  * @remarks
7383
- * - Recipient email addresses are resolved from OAuth connections configured by the app creator. The user running the workflow does not specify the recipient directly.
7411
+ * - Use the "to" field to send to specific email addresses directly. For v2 apps, recipients must be verified users in the app's user table.
7412
+ * - Alternatively, recipient email addresses can be resolved from OAuth connections configured by the app creator via connectionId. The user running the workflow does not specify the recipient directly.
7384
7413
  * - If the body is a URL to a hosted HTML file on the CDN, the HTML is fetched and used as the email body.
7385
7414
  * - When generateHtml is enabled, the body text is converted to a styled HTML email using an AI model.
7386
7415
  * - connectionId can be a comma-separated list to send to multiple recipients.
@@ -7898,6 +7927,8 @@ declare class MindStudioError extends Error {
7898
7927
  status: number,
7899
7928
  /** Raw error body from the API, if available. */
7900
7929
  details?: unknown | undefined);
7930
+ toString(): string;
7931
+ toJSON(): Record<string, unknown>;
7901
7932
  }
7902
7933
 
7903
7934
  type MonacoSnippetFieldType = 'string' | 'number' | 'boolean' | 'array' | 'object' | string[];