@514labs/moose-lib 0.6.457 → 0.6.458

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.
@@ -1083,11 +1083,8 @@ declare class OlapTable<T> extends TypedBase<T, OlapConfig<T>> {
1083
1083
  constructor(name: string, config?: OlapConfig<T>);
1084
1084
  /** @internal **/
1085
1085
  constructor(name: string, config: OlapConfig<T>, schema: IJsonSchemaCollection.IV3_1, columns: Column[], validators?: TypiaValidators<T>, insertValidators?: TypiaValidators<Insertable<T>>);
1086
- /**
1087
- * Generates the versioned table name following Moose's naming convention
1088
- * Format: {tableName}_{version_with_dots_replaced_by_underscores}
1089
- */
1090
- private generateTableName;
1086
+ /** @internal Returns the versioned ClickHouse table name (e.g., "events_1_0_0") */
1087
+ generateTableName(): string;
1091
1088
  /**
1092
1089
  * Creates a fast hash of the ClickHouse configuration.
1093
1090
  * Uses crypto.createHash for better performance than JSON.stringify.
@@ -1893,10 +1890,53 @@ declare class MooseClient {
1893
1890
  workflow: WorkflowClient;
1894
1891
  constructor(queryClient: QueryClient, temporalClient?: Client);
1895
1892
  }
1893
+ /**
1894
+ * Options for per-query ClickHouse row policy enforcement.
1895
+ * When provided, each query activates the specified role and injects
1896
+ * custom settings (e.g., tenant ID) that row policies evaluate via getSetting().
1897
+ */
1898
+ interface RowPolicyOptions {
1899
+ role: string;
1900
+ clickhouse_settings: Record<string, string>;
1901
+ }
1902
+ /**
1903
+ * Shared ClickHouse role name used by all row policies.
1904
+ * IMPORTANT: Must match MOOSE_RLS_ROLE in apps/framework-cli/src/framework/core/infrastructure/select_row_policy.rs
1905
+ */
1906
+ declare const MOOSE_RLS_ROLE = "moose_rls_role";
1907
+ /**
1908
+ * Dedicated ClickHouse user for RLS queries.
1909
+ * Created at DDL time with SELECT-only permissions and the RLS role granted.
1910
+ * IMPORTANT: Must match MOOSE_RLS_USER in apps/framework-cli/src/framework/core/infrastructure/select_row_policy.rs
1911
+ */
1912
+ declare const MOOSE_RLS_USER = "moose_rls_user";
1913
+ /**
1914
+ * Prefix for ClickHouse custom settings used by row policies.
1915
+ * Setting names are `{MOOSE_RLS_SETTING_PREFIX}{column}`.
1916
+ * IMPORTANT: Must match the format in setting_name() in apps/framework-cli/src/framework/core/infrastructure/select_row_policy.rs
1917
+ */
1918
+ declare const MOOSE_RLS_SETTING_PREFIX = "SQL_moose_rls_";
1919
+ /** Config mapping ClickHouse setting names to JWT claim names */
1920
+ type RowPoliciesConfig = Record<string, string>;
1921
+ /**
1922
+ * Build RowPolicyOptions from a row policies config and a claim-value source.
1923
+ * Only sets ClickHouse settings for claims that are present in the source.
1924
+ *
1925
+ * Missing claims are skipped — if a table's row policy calls getSetting()
1926
+ * for a setting that wasn't set, ClickHouse will error. This is correct:
1927
+ * it means the JWT is missing a claim that the queried table requires.
1928
+ * Tables whose policies don't reference the missing setting are unaffected.
1929
+ *
1930
+ * @param config Maps ClickHouse setting name → claim name
1931
+ * @param claims Maps claim name → claim value (e.g., JWT payload or rlsContext)
1932
+ * @returns RowPolicyOptions with the shared RLS role and populated settings
1933
+ */
1934
+ declare function buildRowPolicyOptionsFromClaims(config: RowPoliciesConfig, claims: Record<string, unknown>): RowPolicyOptions;
1896
1935
  declare class QueryClient {
1897
1936
  client: ClickHouseClient;
1898
1937
  query_id_prefix: string;
1899
- constructor(client: ClickHouseClient, query_id_prefix: string);
1938
+ private rowPolicyOptions?;
1939
+ constructor(client: ClickHouseClient, query_id_prefix: string, rowPolicyOptions?: RowPolicyOptions);
1900
1940
  execute<T = any>(sql: Sql): Promise<ResultSet<"JSONEachRow"> & {
1901
1941
  __query_result_t?: T[];
1902
1942
  }>;
@@ -2339,6 +2379,55 @@ declare class SqlResource {
2339
2379
  });
2340
2380
  }
2341
2381
 
2382
+ /** Extract the row type from an OlapTable instance. */
2383
+ type RowOf<T> = T extends OlapTable<infer R> ? R : never;
2384
+ /**
2385
+ * Configuration for a SelectRowPolicy.
2386
+ *
2387
+ * Defines a ClickHouse row policy that filters rows based on a column value
2388
+ * matched against a JWT claim via `getSetting()`.
2389
+ *
2390
+ * The `column` field is type-checked against the columns shared by all
2391
+ * tables — a typo will be caught at compile time.
2392
+ */
2393
+ interface SelectRowPolicyConfig<Tables extends readonly OlapTable<any>[] = readonly OlapTable<any>[]> {
2394
+ /** Tables the policy applies to. Policies propagate through regular Views automatically. */
2395
+ tables: readonly [...Tables];
2396
+ /** Column to filter on (e.g., "org_id"). Must exist in every table. */
2397
+ column: keyof RowOf<Tables[number]> & string;
2398
+ /** JWT claim name that provides the filter value (e.g., "org_id") */
2399
+ claim: string;
2400
+ }
2401
+ /**
2402
+ * Represents a ClickHouse Row Policy as a first-class Moose primitive.
2403
+ *
2404
+ * When defined, Moose generates `CREATE ROW POLICY` DDL that uses
2405
+ * `getSetting('SQL_moose_rls_{column}')` for dynamic per-query tenant scoping.
2406
+ *
2407
+ * @example
2408
+ * ```typescript
2409
+ * export const tenantIsolation = new SelectRowPolicy("tenant_isolation", {
2410
+ * tables: [DataEventTable],
2411
+ * column: "org_id",
2412
+ * claim: "org_id",
2413
+ * });
2414
+ * ```
2415
+ */
2416
+ declare class SelectRowPolicy<Tables extends readonly OlapTable<any>[] = readonly OlapTable<any>[]> {
2417
+ /** @internal */
2418
+ readonly kind = "SelectRowPolicy";
2419
+ /** The name of the row policy */
2420
+ readonly name: string;
2421
+ /** The policy configuration */
2422
+ readonly config: Readonly<SelectRowPolicyConfig<Tables>>;
2423
+ constructor(name: string, config: SelectRowPolicyConfig<Tables>);
2424
+ /** Resolved table references for serialization */
2425
+ get tableRefs(): {
2426
+ name: string;
2427
+ database?: string;
2428
+ }[];
2429
+ }
2430
+
2342
2431
  type WebAppHandler = (req: http.IncomingMessage, res: http.ServerResponse) => void | Promise<void>;
2343
2432
  interface FrameworkApp {
2344
2433
  handle?: (req: http.IncomingMessage, res: http.ServerResponse, next?: (err?: any) => void) => void;
@@ -2483,6 +2572,17 @@ declare function getViews(): Map<string, View>;
2483
2572
  * @returns The View instance or undefined if not found
2484
2573
  */
2485
2574
  declare function getView(name: string): View | undefined;
2575
+ /**
2576
+ * Get all registered row policies.
2577
+ * @returns A Map of policy name to SelectRowPolicy instance
2578
+ */
2579
+ declare function getSelectRowPolicies(): Map<string, SelectRowPolicy>;
2580
+ /**
2581
+ * Get a registered row policy by name.
2582
+ * @param name - The name of the row policy
2583
+ * @returns The SelectRowPolicy instance or undefined if not found
2584
+ */
2585
+ declare function getSelectRowPolicy(name: string): SelectRowPolicy | undefined;
2486
2586
 
2487
2587
  /**
2488
2588
  * @module dmv2
@@ -2524,4 +2624,4 @@ type SimpleAggregated<AggregationFunction extends string, ArgType = any> = {
2524
2624
  _argType?: ArgType;
2525
2625
  };
2526
2626
 
2527
- export { type ClickHouseInt as $, type Aggregated as A, getSqlResource as B, ClickHouseEngines as C, type DeadLetterModel as D, type EgressConfig as E, type FrameworkApp as F, getWorkflows as G, getWorkflow as H, IngestApi as I, getWebApps as J, getWebApp as K, LifeCycle as L, MaterializedView as M, getView as N, OlapTable as O, getViews as P, getMaterializedView as Q, getMaterializedViews as R, type SimpleAggregated as S, Task as T, type ClickHousePrecision as U, View as V, Workflow as W, type ClickHouseDecimal as X, type ClickHouseByteSize as Y, type ClickHouseFixedStringSize as Z, type ClickHouseFloat as _, type OlapConfig as a, type MaterializedViewConfig as a$, type ClickHouseJson as a0, type LowCardinality as a1, type ClickHouseNamedTuple as a2, type ClickHouseDefault as a3, type ClickHouseTTL as a4, type ClickHouseMaterialized as a5, type ClickHouseAlias as a6, type WithDefault as a7, type ClickHouseCodec as a8, type DateTime as a9, toStaticQuery as aA, toQuery as aB, toQueryPreview as aC, getValueFromParameter as aD, createClickhouseParameter as aE, mapToClickHouseType as aF, type MooseUtils as aG, MooseClient as aH, type Column as aI, QueryClient as aJ, type DataType as aK, type ClickHousePoint as aL, type ClickHouseRing as aM, type ClickHouseLineString as aN, type ClickHouseMultiLineString as aO, type ClickHousePolygon as aP, type ClickHouseMultiPolygon as aQ, WorkflowClient as aR, getTemporalClient as aS, ApiHelpers as aT, ConsumptionHelpers as aU, joinQueries as aV, type ConsumerConfig as aW, type TransformConfig as aX, type TaskContext as aY, type TaskConfig as aZ, type IngestPipelineConfig as a_, type DateTime64 as aa, type DateTimeString as ab, type DateTime64String as ac, type FixedString as ad, type Float32 as ae, type Float64 as af, type Int8 as ag, type Int16 as ah, type Int32 as ai, type Int64 as aj, type UInt8 as ak, type UInt16 as al, type UInt32 as am, type UInt64 as an, type Decimal as ao, type Insertable as ap, type ApiUtil as aq, type ConsumptionUtil as ar, quoteIdentifier as as, type IdentifierBrandedString as at, type NonIdentifierBrandedString as au, type Value as av, type RawValue as aw, type SqlTemplateTag as ax, sql as ay, Sql as az, type S3QueueTableSettings as b, Stream as c, type StreamConfig as d, type DeadLetter as e, DeadLetterQueue as f, type IngestConfig as g, Api as h, type ApiConfig as i, ConsumptionApi as j, IngestPipeline as k, SqlResource as l, ETLPipeline as m, type ETLPipelineConfig as n, WebApp as o, type WebAppConfig as p, type WebAppHandler as q, getTables as r, getTable as s, getStreams as t, getStream as u, getIngestApis as v, getIngestApi as w, getApis as x, getApi as y, getSqlResources as z };
2627
+ export { type ClickHouseDecimal as $, type Aggregated as A, getApi as B, ClickHouseEngines as C, type DeadLetterModel as D, type EgressConfig as E, type FrameworkApp as F, getSqlResources as G, getSqlResource as H, IngestApi as I, getWorkflows as J, getWorkflow as K, LifeCycle as L, MaterializedView as M, getWebApps as N, OlapTable as O, getWebApp as P, getView as Q, getViews as R, type SimpleAggregated as S, Task as T, getMaterializedView as U, View as V, Workflow as W, getMaterializedViews as X, getSelectRowPolicies as Y, getSelectRowPolicy as Z, type ClickHousePrecision as _, type OlapConfig as a, WorkflowClient as a$, type ClickHouseByteSize as a0, type ClickHouseFixedStringSize as a1, type ClickHouseFloat as a2, type ClickHouseInt as a3, type ClickHouseJson as a4, type LowCardinality as a5, type ClickHouseNamedTuple as a6, type ClickHouseDefault as a7, type ClickHouseTTL as a8, type ClickHouseMaterialized as a9, type RawValue as aA, type SqlTemplateTag as aB, sql as aC, Sql as aD, toStaticQuery as aE, toQuery as aF, toQueryPreview as aG, getValueFromParameter as aH, createClickhouseParameter as aI, mapToClickHouseType as aJ, type MooseUtils as aK, MooseClient as aL, type Column as aM, QueryClient as aN, type DataType as aO, type ClickHousePoint as aP, type ClickHouseRing as aQ, type ClickHouseLineString as aR, type ClickHouseMultiLineString as aS, type ClickHousePolygon as aT, type ClickHouseMultiPolygon as aU, type RowPolicyOptions as aV, MOOSE_RLS_ROLE as aW, MOOSE_RLS_USER as aX, MOOSE_RLS_SETTING_PREFIX as aY, type RowPoliciesConfig as aZ, buildRowPolicyOptionsFromClaims as a_, type ClickHouseAlias as aa, type WithDefault as ab, type ClickHouseCodec as ac, type DateTime as ad, type DateTime64 as ae, type DateTimeString as af, type DateTime64String as ag, type FixedString as ah, type Float32 as ai, type Float64 as aj, type Int8 as ak, type Int16 as al, type Int32 as am, type Int64 as an, type UInt8 as ao, type UInt16 as ap, type UInt32 as aq, type UInt64 as ar, type Decimal as as, type Insertable as at, type ApiUtil as au, type ConsumptionUtil as av, quoteIdentifier as aw, type IdentifierBrandedString as ax, type NonIdentifierBrandedString as ay, type Value as az, type S3QueueTableSettings as b, getTemporalClient as b0, ApiHelpers as b1, ConsumptionHelpers as b2, joinQueries as b3, type ConsumerConfig as b4, type TransformConfig as b5, type TaskContext as b6, type TaskConfig as b7, type IngestPipelineConfig as b8, type MaterializedViewConfig as b9, Stream as c, type StreamConfig as d, type DeadLetter as e, DeadLetterQueue as f, type IngestConfig as g, Api as h, type ApiConfig as i, ConsumptionApi as j, IngestPipeline as k, SqlResource as l, SelectRowPolicy as m, type SelectRowPolicyConfig as n, ETLPipeline as o, type ETLPipelineConfig as p, WebApp as q, type WebAppConfig as r, type WebAppHandler as s, getTables as t, getTable as u, getStreams as v, getStream as w, getIngestApis as x, getIngestApi as y, getApis as z };
@@ -1083,11 +1083,8 @@ declare class OlapTable<T> extends TypedBase<T, OlapConfig<T>> {
1083
1083
  constructor(name: string, config?: OlapConfig<T>);
1084
1084
  /** @internal **/
1085
1085
  constructor(name: string, config: OlapConfig<T>, schema: IJsonSchemaCollection.IV3_1, columns: Column[], validators?: TypiaValidators<T>, insertValidators?: TypiaValidators<Insertable<T>>);
1086
- /**
1087
- * Generates the versioned table name following Moose's naming convention
1088
- * Format: {tableName}_{version_with_dots_replaced_by_underscores}
1089
- */
1090
- private generateTableName;
1086
+ /** @internal Returns the versioned ClickHouse table name (e.g., "events_1_0_0") */
1087
+ generateTableName(): string;
1091
1088
  /**
1092
1089
  * Creates a fast hash of the ClickHouse configuration.
1093
1090
  * Uses crypto.createHash for better performance than JSON.stringify.
@@ -1893,10 +1890,53 @@ declare class MooseClient {
1893
1890
  workflow: WorkflowClient;
1894
1891
  constructor(queryClient: QueryClient, temporalClient?: Client);
1895
1892
  }
1893
+ /**
1894
+ * Options for per-query ClickHouse row policy enforcement.
1895
+ * When provided, each query activates the specified role and injects
1896
+ * custom settings (e.g., tenant ID) that row policies evaluate via getSetting().
1897
+ */
1898
+ interface RowPolicyOptions {
1899
+ role: string;
1900
+ clickhouse_settings: Record<string, string>;
1901
+ }
1902
+ /**
1903
+ * Shared ClickHouse role name used by all row policies.
1904
+ * IMPORTANT: Must match MOOSE_RLS_ROLE in apps/framework-cli/src/framework/core/infrastructure/select_row_policy.rs
1905
+ */
1906
+ declare const MOOSE_RLS_ROLE = "moose_rls_role";
1907
+ /**
1908
+ * Dedicated ClickHouse user for RLS queries.
1909
+ * Created at DDL time with SELECT-only permissions and the RLS role granted.
1910
+ * IMPORTANT: Must match MOOSE_RLS_USER in apps/framework-cli/src/framework/core/infrastructure/select_row_policy.rs
1911
+ */
1912
+ declare const MOOSE_RLS_USER = "moose_rls_user";
1913
+ /**
1914
+ * Prefix for ClickHouse custom settings used by row policies.
1915
+ * Setting names are `{MOOSE_RLS_SETTING_PREFIX}{column}`.
1916
+ * IMPORTANT: Must match the format in setting_name() in apps/framework-cli/src/framework/core/infrastructure/select_row_policy.rs
1917
+ */
1918
+ declare const MOOSE_RLS_SETTING_PREFIX = "SQL_moose_rls_";
1919
+ /** Config mapping ClickHouse setting names to JWT claim names */
1920
+ type RowPoliciesConfig = Record<string, string>;
1921
+ /**
1922
+ * Build RowPolicyOptions from a row policies config and a claim-value source.
1923
+ * Only sets ClickHouse settings for claims that are present in the source.
1924
+ *
1925
+ * Missing claims are skipped — if a table's row policy calls getSetting()
1926
+ * for a setting that wasn't set, ClickHouse will error. This is correct:
1927
+ * it means the JWT is missing a claim that the queried table requires.
1928
+ * Tables whose policies don't reference the missing setting are unaffected.
1929
+ *
1930
+ * @param config Maps ClickHouse setting name → claim name
1931
+ * @param claims Maps claim name → claim value (e.g., JWT payload or rlsContext)
1932
+ * @returns RowPolicyOptions with the shared RLS role and populated settings
1933
+ */
1934
+ declare function buildRowPolicyOptionsFromClaims(config: RowPoliciesConfig, claims: Record<string, unknown>): RowPolicyOptions;
1896
1935
  declare class QueryClient {
1897
1936
  client: ClickHouseClient;
1898
1937
  query_id_prefix: string;
1899
- constructor(client: ClickHouseClient, query_id_prefix: string);
1938
+ private rowPolicyOptions?;
1939
+ constructor(client: ClickHouseClient, query_id_prefix: string, rowPolicyOptions?: RowPolicyOptions);
1900
1940
  execute<T = any>(sql: Sql): Promise<ResultSet<"JSONEachRow"> & {
1901
1941
  __query_result_t?: T[];
1902
1942
  }>;
@@ -2339,6 +2379,55 @@ declare class SqlResource {
2339
2379
  });
2340
2380
  }
2341
2381
 
2382
+ /** Extract the row type from an OlapTable instance. */
2383
+ type RowOf<T> = T extends OlapTable<infer R> ? R : never;
2384
+ /**
2385
+ * Configuration for a SelectRowPolicy.
2386
+ *
2387
+ * Defines a ClickHouse row policy that filters rows based on a column value
2388
+ * matched against a JWT claim via `getSetting()`.
2389
+ *
2390
+ * The `column` field is type-checked against the columns shared by all
2391
+ * tables — a typo will be caught at compile time.
2392
+ */
2393
+ interface SelectRowPolicyConfig<Tables extends readonly OlapTable<any>[] = readonly OlapTable<any>[]> {
2394
+ /** Tables the policy applies to. Policies propagate through regular Views automatically. */
2395
+ tables: readonly [...Tables];
2396
+ /** Column to filter on (e.g., "org_id"). Must exist in every table. */
2397
+ column: keyof RowOf<Tables[number]> & string;
2398
+ /** JWT claim name that provides the filter value (e.g., "org_id") */
2399
+ claim: string;
2400
+ }
2401
+ /**
2402
+ * Represents a ClickHouse Row Policy as a first-class Moose primitive.
2403
+ *
2404
+ * When defined, Moose generates `CREATE ROW POLICY` DDL that uses
2405
+ * `getSetting('SQL_moose_rls_{column}')` for dynamic per-query tenant scoping.
2406
+ *
2407
+ * @example
2408
+ * ```typescript
2409
+ * export const tenantIsolation = new SelectRowPolicy("tenant_isolation", {
2410
+ * tables: [DataEventTable],
2411
+ * column: "org_id",
2412
+ * claim: "org_id",
2413
+ * });
2414
+ * ```
2415
+ */
2416
+ declare class SelectRowPolicy<Tables extends readonly OlapTable<any>[] = readonly OlapTable<any>[]> {
2417
+ /** @internal */
2418
+ readonly kind = "SelectRowPolicy";
2419
+ /** The name of the row policy */
2420
+ readonly name: string;
2421
+ /** The policy configuration */
2422
+ readonly config: Readonly<SelectRowPolicyConfig<Tables>>;
2423
+ constructor(name: string, config: SelectRowPolicyConfig<Tables>);
2424
+ /** Resolved table references for serialization */
2425
+ get tableRefs(): {
2426
+ name: string;
2427
+ database?: string;
2428
+ }[];
2429
+ }
2430
+
2342
2431
  type WebAppHandler = (req: http.IncomingMessage, res: http.ServerResponse) => void | Promise<void>;
2343
2432
  interface FrameworkApp {
2344
2433
  handle?: (req: http.IncomingMessage, res: http.ServerResponse, next?: (err?: any) => void) => void;
@@ -2483,6 +2572,17 @@ declare function getViews(): Map<string, View>;
2483
2572
  * @returns The View instance or undefined if not found
2484
2573
  */
2485
2574
  declare function getView(name: string): View | undefined;
2575
+ /**
2576
+ * Get all registered row policies.
2577
+ * @returns A Map of policy name to SelectRowPolicy instance
2578
+ */
2579
+ declare function getSelectRowPolicies(): Map<string, SelectRowPolicy>;
2580
+ /**
2581
+ * Get a registered row policy by name.
2582
+ * @param name - The name of the row policy
2583
+ * @returns The SelectRowPolicy instance or undefined if not found
2584
+ */
2585
+ declare function getSelectRowPolicy(name: string): SelectRowPolicy | undefined;
2486
2586
 
2487
2587
  /**
2488
2588
  * @module dmv2
@@ -2524,4 +2624,4 @@ type SimpleAggregated<AggregationFunction extends string, ArgType = any> = {
2524
2624
  _argType?: ArgType;
2525
2625
  };
2526
2626
 
2527
- export { type ClickHouseInt as $, type Aggregated as A, getSqlResource as B, ClickHouseEngines as C, type DeadLetterModel as D, type EgressConfig as E, type FrameworkApp as F, getWorkflows as G, getWorkflow as H, IngestApi as I, getWebApps as J, getWebApp as K, LifeCycle as L, MaterializedView as M, getView as N, OlapTable as O, getViews as P, getMaterializedView as Q, getMaterializedViews as R, type SimpleAggregated as S, Task as T, type ClickHousePrecision as U, View as V, Workflow as W, type ClickHouseDecimal as X, type ClickHouseByteSize as Y, type ClickHouseFixedStringSize as Z, type ClickHouseFloat as _, type OlapConfig as a, type MaterializedViewConfig as a$, type ClickHouseJson as a0, type LowCardinality as a1, type ClickHouseNamedTuple as a2, type ClickHouseDefault as a3, type ClickHouseTTL as a4, type ClickHouseMaterialized as a5, type ClickHouseAlias as a6, type WithDefault as a7, type ClickHouseCodec as a8, type DateTime as a9, toStaticQuery as aA, toQuery as aB, toQueryPreview as aC, getValueFromParameter as aD, createClickhouseParameter as aE, mapToClickHouseType as aF, type MooseUtils as aG, MooseClient as aH, type Column as aI, QueryClient as aJ, type DataType as aK, type ClickHousePoint as aL, type ClickHouseRing as aM, type ClickHouseLineString as aN, type ClickHouseMultiLineString as aO, type ClickHousePolygon as aP, type ClickHouseMultiPolygon as aQ, WorkflowClient as aR, getTemporalClient as aS, ApiHelpers as aT, ConsumptionHelpers as aU, joinQueries as aV, type ConsumerConfig as aW, type TransformConfig as aX, type TaskContext as aY, type TaskConfig as aZ, type IngestPipelineConfig as a_, type DateTime64 as aa, type DateTimeString as ab, type DateTime64String as ac, type FixedString as ad, type Float32 as ae, type Float64 as af, type Int8 as ag, type Int16 as ah, type Int32 as ai, type Int64 as aj, type UInt8 as ak, type UInt16 as al, type UInt32 as am, type UInt64 as an, type Decimal as ao, type Insertable as ap, type ApiUtil as aq, type ConsumptionUtil as ar, quoteIdentifier as as, type IdentifierBrandedString as at, type NonIdentifierBrandedString as au, type Value as av, type RawValue as aw, type SqlTemplateTag as ax, sql as ay, Sql as az, type S3QueueTableSettings as b, Stream as c, type StreamConfig as d, type DeadLetter as e, DeadLetterQueue as f, type IngestConfig as g, Api as h, type ApiConfig as i, ConsumptionApi as j, IngestPipeline as k, SqlResource as l, ETLPipeline as m, type ETLPipelineConfig as n, WebApp as o, type WebAppConfig as p, type WebAppHandler as q, getTables as r, getTable as s, getStreams as t, getStream as u, getIngestApis as v, getIngestApi as w, getApis as x, getApi as y, getSqlResources as z };
2627
+ export { type ClickHouseDecimal as $, type Aggregated as A, getApi as B, ClickHouseEngines as C, type DeadLetterModel as D, type EgressConfig as E, type FrameworkApp as F, getSqlResources as G, getSqlResource as H, IngestApi as I, getWorkflows as J, getWorkflow as K, LifeCycle as L, MaterializedView as M, getWebApps as N, OlapTable as O, getWebApp as P, getView as Q, getViews as R, type SimpleAggregated as S, Task as T, getMaterializedView as U, View as V, Workflow as W, getMaterializedViews as X, getSelectRowPolicies as Y, getSelectRowPolicy as Z, type ClickHousePrecision as _, type OlapConfig as a, WorkflowClient as a$, type ClickHouseByteSize as a0, type ClickHouseFixedStringSize as a1, type ClickHouseFloat as a2, type ClickHouseInt as a3, type ClickHouseJson as a4, type LowCardinality as a5, type ClickHouseNamedTuple as a6, type ClickHouseDefault as a7, type ClickHouseTTL as a8, type ClickHouseMaterialized as a9, type RawValue as aA, type SqlTemplateTag as aB, sql as aC, Sql as aD, toStaticQuery as aE, toQuery as aF, toQueryPreview as aG, getValueFromParameter as aH, createClickhouseParameter as aI, mapToClickHouseType as aJ, type MooseUtils as aK, MooseClient as aL, type Column as aM, QueryClient as aN, type DataType as aO, type ClickHousePoint as aP, type ClickHouseRing as aQ, type ClickHouseLineString as aR, type ClickHouseMultiLineString as aS, type ClickHousePolygon as aT, type ClickHouseMultiPolygon as aU, type RowPolicyOptions as aV, MOOSE_RLS_ROLE as aW, MOOSE_RLS_USER as aX, MOOSE_RLS_SETTING_PREFIX as aY, type RowPoliciesConfig as aZ, buildRowPolicyOptionsFromClaims as a_, type ClickHouseAlias as aa, type WithDefault as ab, type ClickHouseCodec as ac, type DateTime as ad, type DateTime64 as ae, type DateTimeString as af, type DateTime64String as ag, type FixedString as ah, type Float32 as ai, type Float64 as aj, type Int8 as ak, type Int16 as al, type Int32 as am, type Int64 as an, type UInt8 as ao, type UInt16 as ap, type UInt32 as aq, type UInt64 as ar, type Decimal as as, type Insertable as at, type ApiUtil as au, type ConsumptionUtil as av, quoteIdentifier as aw, type IdentifierBrandedString as ax, type NonIdentifierBrandedString as ay, type Value as az, type S3QueueTableSettings as b, getTemporalClient as b0, ApiHelpers as b1, ConsumptionHelpers as b2, joinQueries as b3, type ConsumerConfig as b4, type TransformConfig as b5, type TaskContext as b6, type TaskConfig as b7, type IngestPipelineConfig as b8, type MaterializedViewConfig as b9, Stream as c, type StreamConfig as d, type DeadLetter as e, DeadLetterQueue as f, type IngestConfig as g, Api as h, type ApiConfig as i, ConsumptionApi as j, IngestPipeline as k, SqlResource as l, SelectRowPolicy as m, type SelectRowPolicyConfig as n, ETLPipeline as o, type ETLPipelineConfig as p, WebApp as q, type WebAppConfig as r, type WebAppHandler as s, getTables as t, getTable as u, getStreams as v, getStream as w, getIngestApis as x, getIngestApi as y, getApis as z };
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { JWT, Key } from './browserCompatible.mjs';
2
2
  import * as _clickhouse_client from '@clickhouse/client';
3
3
  import { KafkaJS } from '@514labs/kafka-javascript';
4
- import { aG as MooseUtils, aH as MooseClient, az as Sql, O as OlapTable, M as MaterializedView, aI as Column, aJ as QueryClient, aK as DataType } from './index-FbIy0gSU.mjs';
5
- export { A as Aggregated, h as Api, i as ApiConfig, aT as ApiHelpers, aq as ApiUtil, a6 as ClickHouseAlias, Y as ClickHouseByteSize, a8 as ClickHouseCodec, X as ClickHouseDecimal, a3 as ClickHouseDefault, C as ClickHouseEngines, Z as ClickHouseFixedStringSize, _ as ClickHouseFloat, $ as ClickHouseInt, a0 as ClickHouseJson, aN as ClickHouseLineString, a5 as ClickHouseMaterialized, aO as ClickHouseMultiLineString, aQ as ClickHouseMultiPolygon, a2 as ClickHouseNamedTuple, aL as ClickHousePoint, aP as ClickHousePolygon, U as ClickHousePrecision, aM as ClickHouseRing, a4 as ClickHouseTTL, j as ConsumptionApi, aU as ConsumptionHelpers, ar as ConsumptionUtil, a9 as DateTime, aa as DateTime64, ac as DateTime64String, ab as DateTimeString, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, ao as Decimal, m as ETLPipeline, n as ETLPipelineConfig, E as EgressConfig, ad as FixedString, ae as Float32, af as Float64, F as FrameworkApp, at as IdentifierBrandedString, I as IngestApi, g as IngestConfig, k as IngestPipeline, ap as Insertable, ah as Int16, ai as Int32, aj as Int64, ag as Int8, L as LifeCycle, a1 as LowCardinality, au as NonIdentifierBrandedString, a as OlapConfig, aw as RawValue, b as S3QueueTableSettings, S as SimpleAggregated, l as SqlResource, ax as SqlTemplateTag, c as Stream, d as StreamConfig, T as Task, al as UInt16, am as UInt32, an as UInt64, ak as UInt8, av as Value, V as View, o as WebApp, p as WebAppConfig, q as WebAppHandler, a7 as WithDefault, W as Workflow, aR as WorkflowClient, aE as createClickhouseParameter, y as getApi, x as getApis, w as getIngestApi, v as getIngestApis, Q as getMaterializedView, R as getMaterializedViews, B as getSqlResource, z as getSqlResources, u as getStream, t as getStreams, s as getTable, r as getTables, aS as getTemporalClient, aD as getValueFromParameter, N as getView, P as getViews, K as getWebApp, J as getWebApps, H as getWorkflow, G as getWorkflows, aV as joinQueries, aF as mapToClickHouseType, as as quoteIdentifier, ay as sql, aB as toQuery, aC as toQueryPreview, aA as toStaticQuery } from './index-FbIy0gSU.mjs';
4
+ import { aK as MooseUtils, aL as MooseClient, aD as Sql, O as OlapTable, M as MaterializedView, aM as Column, aN as QueryClient, aO as DataType } from './index-BkvEUvtm.mjs';
5
+ export { A as Aggregated, h as Api, i as ApiConfig, b1 as ApiHelpers, au as ApiUtil, aa as ClickHouseAlias, a0 as ClickHouseByteSize, ac as ClickHouseCodec, $ as ClickHouseDecimal, a7 as ClickHouseDefault, C as ClickHouseEngines, a1 as ClickHouseFixedStringSize, a2 as ClickHouseFloat, a3 as ClickHouseInt, a4 as ClickHouseJson, aR as ClickHouseLineString, a9 as ClickHouseMaterialized, aS as ClickHouseMultiLineString, aU as ClickHouseMultiPolygon, a6 as ClickHouseNamedTuple, aP as ClickHousePoint, aT as ClickHousePolygon, _ as ClickHousePrecision, aQ as ClickHouseRing, a8 as ClickHouseTTL, j as ConsumptionApi, b2 as ConsumptionHelpers, av as ConsumptionUtil, ad as DateTime, ae as DateTime64, ag as DateTime64String, af as DateTimeString, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, as as Decimal, o as ETLPipeline, p as ETLPipelineConfig, E as EgressConfig, ah as FixedString, ai as Float32, aj as Float64, F as FrameworkApp, ax as IdentifierBrandedString, I as IngestApi, g as IngestConfig, k as IngestPipeline, at as Insertable, al as Int16, am as Int32, an as Int64, ak as Int8, L as LifeCycle, a5 as LowCardinality, aW as MOOSE_RLS_ROLE, aY as MOOSE_RLS_SETTING_PREFIX, aX as MOOSE_RLS_USER, ay as NonIdentifierBrandedString, a as OlapConfig, aA as RawValue, aZ as RowPoliciesConfig, aV as RowPolicyOptions, b as S3QueueTableSettings, m as SelectRowPolicy, n as SelectRowPolicyConfig, S as SimpleAggregated, l as SqlResource, aB as SqlTemplateTag, c as Stream, d as StreamConfig, T as Task, ap as UInt16, aq as UInt32, ar as UInt64, ao as UInt8, az as Value, V as View, q as WebApp, r as WebAppConfig, s as WebAppHandler, ab as WithDefault, W as Workflow, a$ as WorkflowClient, a_ as buildRowPolicyOptionsFromClaims, aI as createClickhouseParameter, B as getApi, z as getApis, y as getIngestApi, x as getIngestApis, U as getMaterializedView, X as getMaterializedViews, Y as getSelectRowPolicies, Z as getSelectRowPolicy, H as getSqlResource, G as getSqlResources, w as getStream, v as getStreams, u as getTable, t as getTables, b0 as getTemporalClient, aH as getValueFromParameter, Q as getView, R as getViews, P as getWebApp, N as getWebApps, K as getWorkflow, J as getWorkflows, b3 as joinQueries, aJ as mapToClickHouseType, aw as quoteIdentifier, aC as sql, aF as toQuery, aG as toQueryPreview, aE as toStaticQuery } from './index-BkvEUvtm.mjs';
6
6
  import http from 'http';
7
7
  import { IsTuple } from 'typia/lib/typings/IsTuple';
8
8
  import { Readable } from 'node:stream';
@@ -375,8 +375,14 @@ interface RuntimeClickHouseConfig {
375
375
  password: string;
376
376
  database: string;
377
377
  useSSL: boolean;
378
+ rlsUser?: string;
379
+ rlsPassword?: string;
378
380
  }
379
381
 
382
+ interface GetMooseUtilsOptions {
383
+ /** Map of JWT claim names to their values for row policy scoping */
384
+ rlsContext?: Record<string, string>;
385
+ }
380
386
  /**
381
387
  * Get Moose utilities for database access and SQL queries.
382
388
  * Works in both Moose runtime and standalone contexts.
@@ -387,21 +393,17 @@ interface RuntimeClickHouseConfig {
387
393
  * const moose = getMooseUtils(); // WRONG - returns Promise, not MooseUtils!
388
394
  * ```
389
395
  *
390
- * **Breaking Change from v1.x**: This function signature changed from sync to async.
391
- * If you were using the old sync API that extracted utils from a request object,
392
- * use `getMooseUtilsFromRequest(req)` for backward compatibility (deprecated).
393
- *
394
- * @param req - DEPRECATED: Request parameter is no longer needed and will be ignored.
395
- * If you need to extract moose from a request, use getMooseUtilsFromRequest().
396
- * @returns Promise resolving to MooseUtils with client and sql utilities.
397
- *
398
- * @example
396
+ * Pass `{ rlsContext }` to get a scoped client that enforces ClickHouse row policies:
399
397
  * ```typescript
400
- * const { client, sql } = await getMooseUtils();
401
- * const result = await client.query.execute(sql`SELECT * FROM table`);
398
+ * const { client, sql } = await getMooseUtils({ rlsContext: { org_id: orgId } });
399
+ * // All queries through this client are filtered by org_id
402
400
  * ```
401
+ *
402
+ * @param options - Optional. Pass `{ rlsContext }` to scope queries via row policies.
403
+ * DEPRECATED: Passing a request object is no longer needed and will be ignored.
404
+ * @returns Promise resolving to MooseUtils with client and sql utilities.
403
405
  */
404
- declare function getMooseUtils(req?: any): Promise<MooseUtils>;
406
+ declare function getMooseUtils(options?: GetMooseUtilsOptions | any): Promise<MooseUtils>;
405
407
  /**
406
408
  * @deprecated Use getMooseUtils() instead.
407
409
  * Creates a Moose client for database access.
@@ -1390,4 +1392,4 @@ type DataModelConfig<T> = Partial<{
1390
1392
  parallelism?: number;
1391
1393
  }>;
1392
1394
 
1393
- export { ACKs, BadRequestError, type CSVParsingConfig, CSV_DELIMITERS, type CliLogData, type ColRef, Column, type ColumnDef, DEFAULT_CSV_CONFIG, DEFAULT_JSON_CONFIG, type DataModelConfig, DataSource, type DataSourceConfig, type DimensionDef, type Expr, type ExpressRequestWithMoose, type ExtractionResult, type FilterDefBase, type FilterInputTypeHint, type FilterOperator, type FilterParams, type JSONParsingConfig, type JoinDef, type KafkaClientConfig, type Logger, MAX_RETRIES, MAX_RETRIES_PRODUCER, MAX_RETRY_TIME_MS, MOOSE_RUNTIME_ENV_PREFIX, MaterializedView, type MetricDef, type ModelFilterDef, type ModelToolOptions, type ModelToolResult, MooseCache, MooseClient, MooseUtils, type Names, OlapTable, type OperatorValueType, type Producer, type QueryBuilder, QueryClient, type QueryHandler, type QueryModel, type QueryModelBase, type QueryModelConfig, type QueryModelFilter, type QueryParts, type QueryRequest, RETRY_FACTOR_PRODUCER, RETRY_INITIAL_TIME_MS, type SortDir, Sql, type SqlValue, type StripDateIntersection, type TaskConfig, type TaskDefinition, type TaskFunction, type ValidationError, and, antiCachePath, as, assertValid, avg, between, buildQuery, cliLog, columnsFromTable, compilerLog, count, countDistinct, createModelTool, createProducerConfig, createQueryHandler, defineQueryModel, deriveInputTypeFromDataType, empty, eq, expressMiddleware, filter, filtersFromTable, getClickhouseClient, getFileName, getKafkaClient, getKafkaProducer, getLegacyMooseUtils, getMooseClients, getMooseUtils, getMooseUtilsFromRequest, groupBy, gt, gte, having, ilike, inList, isEmpty, isNotNull, isNull, isValidCSVDelimiter, join, like, limit, logError, lt, lte, mapTstoJs, max, min, mooseEnvSecrets, mooseRuntimeEnv, ne, not, notIn, offset, or, orderBy, paginate, parseCSV, parseJSON, parseJSONWithDates, raw, registerModelTools, rewriteImportExtensions, select, sum, timeDimensions, where };
1395
+ export { ACKs, BadRequestError, type CSVParsingConfig, CSV_DELIMITERS, type CliLogData, type ColRef, Column, type ColumnDef, DEFAULT_CSV_CONFIG, DEFAULT_JSON_CONFIG, type DataModelConfig, DataSource, type DataSourceConfig, type DimensionDef, type Expr, type ExpressRequestWithMoose, type ExtractionResult, type FilterDefBase, type FilterInputTypeHint, type FilterOperator, type FilterParams, type GetMooseUtilsOptions, type JSONParsingConfig, type JoinDef, type KafkaClientConfig, type Logger, MAX_RETRIES, MAX_RETRIES_PRODUCER, MAX_RETRY_TIME_MS, MOOSE_RUNTIME_ENV_PREFIX, MaterializedView, type MetricDef, type ModelFilterDef, type ModelToolOptions, type ModelToolResult, MooseCache, MooseClient, MooseUtils, type Names, OlapTable, type OperatorValueType, type Producer, type QueryBuilder, QueryClient, type QueryHandler, type QueryModel, type QueryModelBase, type QueryModelConfig, type QueryModelFilter, type QueryParts, type QueryRequest, RETRY_FACTOR_PRODUCER, RETRY_INITIAL_TIME_MS, type SortDir, Sql, type SqlValue, type StripDateIntersection, type TaskConfig, type TaskDefinition, type TaskFunction, type ValidationError, and, antiCachePath, as, assertValid, avg, between, buildQuery, cliLog, columnsFromTable, compilerLog, count, countDistinct, createModelTool, createProducerConfig, createQueryHandler, defineQueryModel, deriveInputTypeFromDataType, empty, eq, expressMiddleware, filter, filtersFromTable, getClickhouseClient, getFileName, getKafkaClient, getKafkaProducer, getLegacyMooseUtils, getMooseClients, getMooseUtils, getMooseUtilsFromRequest, groupBy, gt, gte, having, ilike, inList, isEmpty, isNotNull, isNull, isValidCSVDelimiter, join, like, limit, logError, lt, lte, mapTstoJs, max, min, mooseEnvSecrets, mooseRuntimeEnv, ne, not, notIn, offset, or, orderBy, paginate, parseCSV, parseJSON, parseJSONWithDates, raw, registerModelTools, rewriteImportExtensions, select, sum, timeDimensions, where };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  export { JWT, Key } from './browserCompatible.js';
2
2
  import * as _clickhouse_client from '@clickhouse/client';
3
3
  import { KafkaJS } from '@514labs/kafka-javascript';
4
- import { aG as MooseUtils, aH as MooseClient, az as Sql, O as OlapTable, M as MaterializedView, aI as Column, aJ as QueryClient, aK as DataType } from './index-FbIy0gSU.js';
5
- export { A as Aggregated, h as Api, i as ApiConfig, aT as ApiHelpers, aq as ApiUtil, a6 as ClickHouseAlias, Y as ClickHouseByteSize, a8 as ClickHouseCodec, X as ClickHouseDecimal, a3 as ClickHouseDefault, C as ClickHouseEngines, Z as ClickHouseFixedStringSize, _ as ClickHouseFloat, $ as ClickHouseInt, a0 as ClickHouseJson, aN as ClickHouseLineString, a5 as ClickHouseMaterialized, aO as ClickHouseMultiLineString, aQ as ClickHouseMultiPolygon, a2 as ClickHouseNamedTuple, aL as ClickHousePoint, aP as ClickHousePolygon, U as ClickHousePrecision, aM as ClickHouseRing, a4 as ClickHouseTTL, j as ConsumptionApi, aU as ConsumptionHelpers, ar as ConsumptionUtil, a9 as DateTime, aa as DateTime64, ac as DateTime64String, ab as DateTimeString, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, ao as Decimal, m as ETLPipeline, n as ETLPipelineConfig, E as EgressConfig, ad as FixedString, ae as Float32, af as Float64, F as FrameworkApp, at as IdentifierBrandedString, I as IngestApi, g as IngestConfig, k as IngestPipeline, ap as Insertable, ah as Int16, ai as Int32, aj as Int64, ag as Int8, L as LifeCycle, a1 as LowCardinality, au as NonIdentifierBrandedString, a as OlapConfig, aw as RawValue, b as S3QueueTableSettings, S as SimpleAggregated, l as SqlResource, ax as SqlTemplateTag, c as Stream, d as StreamConfig, T as Task, al as UInt16, am as UInt32, an as UInt64, ak as UInt8, av as Value, V as View, o as WebApp, p as WebAppConfig, q as WebAppHandler, a7 as WithDefault, W as Workflow, aR as WorkflowClient, aE as createClickhouseParameter, y as getApi, x as getApis, w as getIngestApi, v as getIngestApis, Q as getMaterializedView, R as getMaterializedViews, B as getSqlResource, z as getSqlResources, u as getStream, t as getStreams, s as getTable, r as getTables, aS as getTemporalClient, aD as getValueFromParameter, N as getView, P as getViews, K as getWebApp, J as getWebApps, H as getWorkflow, G as getWorkflows, aV as joinQueries, aF as mapToClickHouseType, as as quoteIdentifier, ay as sql, aB as toQuery, aC as toQueryPreview, aA as toStaticQuery } from './index-FbIy0gSU.js';
4
+ import { aK as MooseUtils, aL as MooseClient, aD as Sql, O as OlapTable, M as MaterializedView, aM as Column, aN as QueryClient, aO as DataType } from './index-BkvEUvtm.js';
5
+ export { A as Aggregated, h as Api, i as ApiConfig, b1 as ApiHelpers, au as ApiUtil, aa as ClickHouseAlias, a0 as ClickHouseByteSize, ac as ClickHouseCodec, $ as ClickHouseDecimal, a7 as ClickHouseDefault, C as ClickHouseEngines, a1 as ClickHouseFixedStringSize, a2 as ClickHouseFloat, a3 as ClickHouseInt, a4 as ClickHouseJson, aR as ClickHouseLineString, a9 as ClickHouseMaterialized, aS as ClickHouseMultiLineString, aU as ClickHouseMultiPolygon, a6 as ClickHouseNamedTuple, aP as ClickHousePoint, aT as ClickHousePolygon, _ as ClickHousePrecision, aQ as ClickHouseRing, a8 as ClickHouseTTL, j as ConsumptionApi, b2 as ConsumptionHelpers, av as ConsumptionUtil, ad as DateTime, ae as DateTime64, ag as DateTime64String, af as DateTimeString, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, as as Decimal, o as ETLPipeline, p as ETLPipelineConfig, E as EgressConfig, ah as FixedString, ai as Float32, aj as Float64, F as FrameworkApp, ax as IdentifierBrandedString, I as IngestApi, g as IngestConfig, k as IngestPipeline, at as Insertable, al as Int16, am as Int32, an as Int64, ak as Int8, L as LifeCycle, a5 as LowCardinality, aW as MOOSE_RLS_ROLE, aY as MOOSE_RLS_SETTING_PREFIX, aX as MOOSE_RLS_USER, ay as NonIdentifierBrandedString, a as OlapConfig, aA as RawValue, aZ as RowPoliciesConfig, aV as RowPolicyOptions, b as S3QueueTableSettings, m as SelectRowPolicy, n as SelectRowPolicyConfig, S as SimpleAggregated, l as SqlResource, aB as SqlTemplateTag, c as Stream, d as StreamConfig, T as Task, ap as UInt16, aq as UInt32, ar as UInt64, ao as UInt8, az as Value, V as View, q as WebApp, r as WebAppConfig, s as WebAppHandler, ab as WithDefault, W as Workflow, a$ as WorkflowClient, a_ as buildRowPolicyOptionsFromClaims, aI as createClickhouseParameter, B as getApi, z as getApis, y as getIngestApi, x as getIngestApis, U as getMaterializedView, X as getMaterializedViews, Y as getSelectRowPolicies, Z as getSelectRowPolicy, H as getSqlResource, G as getSqlResources, w as getStream, v as getStreams, u as getTable, t as getTables, b0 as getTemporalClient, aH as getValueFromParameter, Q as getView, R as getViews, P as getWebApp, N as getWebApps, K as getWorkflow, J as getWorkflows, b3 as joinQueries, aJ as mapToClickHouseType, aw as quoteIdentifier, aC as sql, aF as toQuery, aG as toQueryPreview, aE as toStaticQuery } from './index-BkvEUvtm.js';
6
6
  import http from 'http';
7
7
  import { IsTuple } from 'typia/lib/typings/IsTuple';
8
8
  import { Readable } from 'node:stream';
@@ -375,8 +375,14 @@ interface RuntimeClickHouseConfig {
375
375
  password: string;
376
376
  database: string;
377
377
  useSSL: boolean;
378
+ rlsUser?: string;
379
+ rlsPassword?: string;
378
380
  }
379
381
 
382
+ interface GetMooseUtilsOptions {
383
+ /** Map of JWT claim names to their values for row policy scoping */
384
+ rlsContext?: Record<string, string>;
385
+ }
380
386
  /**
381
387
  * Get Moose utilities for database access and SQL queries.
382
388
  * Works in both Moose runtime and standalone contexts.
@@ -387,21 +393,17 @@ interface RuntimeClickHouseConfig {
387
393
  * const moose = getMooseUtils(); // WRONG - returns Promise, not MooseUtils!
388
394
  * ```
389
395
  *
390
- * **Breaking Change from v1.x**: This function signature changed from sync to async.
391
- * If you were using the old sync API that extracted utils from a request object,
392
- * use `getMooseUtilsFromRequest(req)` for backward compatibility (deprecated).
393
- *
394
- * @param req - DEPRECATED: Request parameter is no longer needed and will be ignored.
395
- * If you need to extract moose from a request, use getMooseUtilsFromRequest().
396
- * @returns Promise resolving to MooseUtils with client and sql utilities.
397
- *
398
- * @example
396
+ * Pass `{ rlsContext }` to get a scoped client that enforces ClickHouse row policies:
399
397
  * ```typescript
400
- * const { client, sql } = await getMooseUtils();
401
- * const result = await client.query.execute(sql`SELECT * FROM table`);
398
+ * const { client, sql } = await getMooseUtils({ rlsContext: { org_id: orgId } });
399
+ * // All queries through this client are filtered by org_id
402
400
  * ```
401
+ *
402
+ * @param options - Optional. Pass `{ rlsContext }` to scope queries via row policies.
403
+ * DEPRECATED: Passing a request object is no longer needed and will be ignored.
404
+ * @returns Promise resolving to MooseUtils with client and sql utilities.
403
405
  */
404
- declare function getMooseUtils(req?: any): Promise<MooseUtils>;
406
+ declare function getMooseUtils(options?: GetMooseUtilsOptions | any): Promise<MooseUtils>;
405
407
  /**
406
408
  * @deprecated Use getMooseUtils() instead.
407
409
  * Creates a Moose client for database access.
@@ -1390,4 +1392,4 @@ type DataModelConfig<T> = Partial<{
1390
1392
  parallelism?: number;
1391
1393
  }>;
1392
1394
 
1393
- export { ACKs, BadRequestError, type CSVParsingConfig, CSV_DELIMITERS, type CliLogData, type ColRef, Column, type ColumnDef, DEFAULT_CSV_CONFIG, DEFAULT_JSON_CONFIG, type DataModelConfig, DataSource, type DataSourceConfig, type DimensionDef, type Expr, type ExpressRequestWithMoose, type ExtractionResult, type FilterDefBase, type FilterInputTypeHint, type FilterOperator, type FilterParams, type JSONParsingConfig, type JoinDef, type KafkaClientConfig, type Logger, MAX_RETRIES, MAX_RETRIES_PRODUCER, MAX_RETRY_TIME_MS, MOOSE_RUNTIME_ENV_PREFIX, MaterializedView, type MetricDef, type ModelFilterDef, type ModelToolOptions, type ModelToolResult, MooseCache, MooseClient, MooseUtils, type Names, OlapTable, type OperatorValueType, type Producer, type QueryBuilder, QueryClient, type QueryHandler, type QueryModel, type QueryModelBase, type QueryModelConfig, type QueryModelFilter, type QueryParts, type QueryRequest, RETRY_FACTOR_PRODUCER, RETRY_INITIAL_TIME_MS, type SortDir, Sql, type SqlValue, type StripDateIntersection, type TaskConfig, type TaskDefinition, type TaskFunction, type ValidationError, and, antiCachePath, as, assertValid, avg, between, buildQuery, cliLog, columnsFromTable, compilerLog, count, countDistinct, createModelTool, createProducerConfig, createQueryHandler, defineQueryModel, deriveInputTypeFromDataType, empty, eq, expressMiddleware, filter, filtersFromTable, getClickhouseClient, getFileName, getKafkaClient, getKafkaProducer, getLegacyMooseUtils, getMooseClients, getMooseUtils, getMooseUtilsFromRequest, groupBy, gt, gte, having, ilike, inList, isEmpty, isNotNull, isNull, isValidCSVDelimiter, join, like, limit, logError, lt, lte, mapTstoJs, max, min, mooseEnvSecrets, mooseRuntimeEnv, ne, not, notIn, offset, or, orderBy, paginate, parseCSV, parseJSON, parseJSONWithDates, raw, registerModelTools, rewriteImportExtensions, select, sum, timeDimensions, where };
1395
+ export { ACKs, BadRequestError, type CSVParsingConfig, CSV_DELIMITERS, type CliLogData, type ColRef, Column, type ColumnDef, DEFAULT_CSV_CONFIG, DEFAULT_JSON_CONFIG, type DataModelConfig, DataSource, type DataSourceConfig, type DimensionDef, type Expr, type ExpressRequestWithMoose, type ExtractionResult, type FilterDefBase, type FilterInputTypeHint, type FilterOperator, type FilterParams, type GetMooseUtilsOptions, type JSONParsingConfig, type JoinDef, type KafkaClientConfig, type Logger, MAX_RETRIES, MAX_RETRIES_PRODUCER, MAX_RETRY_TIME_MS, MOOSE_RUNTIME_ENV_PREFIX, MaterializedView, type MetricDef, type ModelFilterDef, type ModelToolOptions, type ModelToolResult, MooseCache, MooseClient, MooseUtils, type Names, OlapTable, type OperatorValueType, type Producer, type QueryBuilder, QueryClient, type QueryHandler, type QueryModel, type QueryModelBase, type QueryModelConfig, type QueryModelFilter, type QueryParts, type QueryRequest, RETRY_FACTOR_PRODUCER, RETRY_INITIAL_TIME_MS, type SortDir, Sql, type SqlValue, type StripDateIntersection, type TaskConfig, type TaskDefinition, type TaskFunction, type ValidationError, and, antiCachePath, as, assertValid, avg, between, buildQuery, cliLog, columnsFromTable, compilerLog, count, countDistinct, createModelTool, createProducerConfig, createQueryHandler, defineQueryModel, deriveInputTypeFromDataType, empty, eq, expressMiddleware, filter, filtersFromTable, getClickhouseClient, getFileName, getKafkaClient, getKafkaProducer, getLegacyMooseUtils, getMooseClients, getMooseUtils, getMooseUtilsFromRequest, groupBy, gt, gte, having, ilike, inList, isEmpty, isNotNull, isNull, isValidCSVDelimiter, join, like, limit, logError, lt, lte, mapTstoJs, max, min, mooseEnvSecrets, mooseRuntimeEnv, ne, not, notIn, offset, or, orderBy, paginate, parseCSV, parseJSON, parseJSONWithDates, raw, registerModelTools, rewriteImportExtensions, select, sum, timeDimensions, where };