@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.
@@ -1,4 +1,4 @@
1
- export { A as Aggregated, h as Api, i as ApiConfig, C as ClickHouseEngines, aW as ConsumerConfig, j as ConsumptionApi, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, m as ETLPipeline, n as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, I as IngestApi, g as IngestConfig, k as IngestPipeline, a_ as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, a$ as MaterializedViewConfig, a as OlapConfig, O as OlapTable, b as S3QueueTableSettings, S as SimpleAggregated, l as SqlResource, c as Stream, d as StreamConfig, T as Task, aZ as TaskConfig, aY as TaskContext, aX as TransformConfig, V as View, o as WebApp, p as WebAppConfig, q as WebAppHandler, W as Workflow, 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, N as getView, P as getViews, K as getWebApp, J as getWebApps, H as getWorkflow, G as getWorkflows } from '../index-FbIy0gSU.mjs';
1
+ export { A as Aggregated, h as Api, i as ApiConfig, C as ClickHouseEngines, b4 as ConsumerConfig, j as ConsumptionApi, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, o as ETLPipeline, p as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, I as IngestApi, g as IngestConfig, k as IngestPipeline, b8 as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, b9 as MaterializedViewConfig, a as OlapConfig, O as OlapTable, b as S3QueueTableSettings, m as SelectRowPolicy, n as SelectRowPolicyConfig, S as SimpleAggregated, l as SqlResource, c as Stream, d as StreamConfig, T as Task, b7 as TaskConfig, b6 as TaskContext, b5 as TransformConfig, V as View, q as WebApp, r as WebAppConfig, s as WebAppHandler, W as Workflow, 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, Q as getView, R as getViews, P as getWebApp, N as getWebApps, K as getWorkflow, J as getWorkflows } from '../index-BkvEUvtm.mjs';
2
2
  import 'typia';
3
3
  import 'typia/lib/tags';
4
4
  import 'node:stream';
@@ -1,4 +1,4 @@
1
- export { A as Aggregated, h as Api, i as ApiConfig, C as ClickHouseEngines, aW as ConsumerConfig, j as ConsumptionApi, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, m as ETLPipeline, n as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, I as IngestApi, g as IngestConfig, k as IngestPipeline, a_ as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, a$ as MaterializedViewConfig, a as OlapConfig, O as OlapTable, b as S3QueueTableSettings, S as SimpleAggregated, l as SqlResource, c as Stream, d as StreamConfig, T as Task, aZ as TaskConfig, aY as TaskContext, aX as TransformConfig, V as View, o as WebApp, p as WebAppConfig, q as WebAppHandler, W as Workflow, 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, N as getView, P as getViews, K as getWebApp, J as getWebApps, H as getWorkflow, G as getWorkflows } from '../index-FbIy0gSU.js';
1
+ export { A as Aggregated, h as Api, i as ApiConfig, C as ClickHouseEngines, b4 as ConsumerConfig, j as ConsumptionApi, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, o as ETLPipeline, p as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, I as IngestApi, g as IngestConfig, k as IngestPipeline, b8 as IngestPipelineConfig, L as LifeCycle, M as MaterializedView, b9 as MaterializedViewConfig, a as OlapConfig, O as OlapTable, b as S3QueueTableSettings, m as SelectRowPolicy, n as SelectRowPolicyConfig, S as SimpleAggregated, l as SqlResource, c as Stream, d as StreamConfig, T as Task, b7 as TaskConfig, b6 as TaskContext, b5 as TransformConfig, V as View, q as WebApp, r as WebAppConfig, s as WebAppHandler, W as Workflow, 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, Q as getView, R as getViews, P as getWebApp, N as getWebApps, K as getWorkflow, J as getWorkflows } from '../index-BkvEUvtm.js';
2
2
  import 'typia';
3
3
  import 'typia/lib/tags';
4
4
  import 'node:stream';
@@ -395,13 +395,17 @@ var init_runtime = __esm({
395
395
  const envUseSSL = this._parseBool(
396
396
  this._env("MOOSE_CLICKHOUSE_CONFIG__USE_SSL")
397
397
  );
398
+ const envRlsUser = this._env("MOOSE_CLICKHOUSE_CONFIG__RLS_USER");
399
+ const envRlsPassword = this._env("MOOSE_CLICKHOUSE_CONFIG__RLS_PASSWORD");
398
400
  return {
399
401
  host: envHost ?? projectConfig.clickhouse_config.host,
400
402
  port: envPort ?? projectConfig.clickhouse_config.host_port.toString(),
401
403
  username: envUser ?? projectConfig.clickhouse_config.user,
402
404
  password: envPassword ?? projectConfig.clickhouse_config.password,
403
405
  database: envDb ?? projectConfig.clickhouse_config.db_name,
404
- useSSL: envUseSSL !== void 0 ? envUseSSL : projectConfig.clickhouse_config.use_ssl || false
406
+ useSSL: envUseSSL !== void 0 ? envUseSSL : projectConfig.clickhouse_config.use_ssl || false,
407
+ rlsUser: envRlsUser ?? projectConfig.clickhouse_config.rls_user ?? void 0,
408
+ rlsPassword: envRlsPassword ?? projectConfig.clickhouse_config.rls_password ?? void 0
405
409
  };
406
410
  }
407
411
  async getStandaloneClickhouseConfig(overrides) {
@@ -416,6 +420,8 @@ var init_runtime = __esm({
416
420
  const envUseSSL = this._parseBool(
417
421
  this._env("MOOSE_CLICKHOUSE_CONFIG__USE_SSL")
418
422
  );
423
+ const envRlsUser = this._env("MOOSE_CLICKHOUSE_CONFIG__RLS_USER");
424
+ const envRlsPassword = this._env("MOOSE_CLICKHOUSE_CONFIG__RLS_PASSWORD");
419
425
  let projectConfig;
420
426
  try {
421
427
  projectConfig = await readProjectConfig();
@@ -436,7 +442,9 @@ var init_runtime = __esm({
436
442
  username: overrides?.username ?? envUser ?? projectConfig?.clickhouse_config.user ?? defaults.username,
437
443
  password: overrides?.password ?? envPassword ?? projectConfig?.clickhouse_config.password ?? defaults.password,
438
444
  database: overrides?.database ?? envDb ?? projectConfig?.clickhouse_config.db_name ?? defaults.database,
439
- useSSL: overrides?.useSSL ?? envUseSSL ?? projectConfig?.clickhouse_config.use_ssl ?? defaults.useSSL
445
+ useSSL: overrides?.useSSL ?? envUseSSL ?? projectConfig?.clickhouse_config.use_ssl ?? defaults.useSSL,
446
+ rlsUser: envRlsUser ?? projectConfig?.clickhouse_config.rls_user ?? void 0,
447
+ rlsPassword: envRlsPassword ?? projectConfig?.clickhouse_config.rls_password ?? void 0
440
448
  };
441
449
  }
442
450
  async getKafkaConfig() {
@@ -485,6 +493,7 @@ __export(dmv2_exports, {
485
493
  LifeCycle: () => LifeCycle,
486
494
  MaterializedView: () => MaterializedView,
487
495
  OlapTable: () => OlapTable,
496
+ SelectRowPolicy: () => SelectRowPolicy,
488
497
  SqlResource: () => SqlResource,
489
498
  Stream: () => Stream,
490
499
  Task: () => Task,
@@ -497,6 +506,8 @@ __export(dmv2_exports, {
497
506
  getIngestApis: () => getIngestApis,
498
507
  getMaterializedView: () => getMaterializedView,
499
508
  getMaterializedViews: () => getMaterializedViews,
509
+ getSelectRowPolicies: () => getSelectRowPolicies,
510
+ getSelectRowPolicy: () => getSelectRowPolicy,
500
511
  getSqlResource: () => getSqlResource,
501
512
  getSqlResources: () => getSqlResources,
502
513
  getStream: () => getStream,
@@ -839,6 +850,93 @@ var import_redis = require("redis");
839
850
  // src/consumption-apis/standalone.ts
840
851
  init_commons();
841
852
 
853
+ // src/dmv2/registry.ts
854
+ function getTables() {
855
+ return getMooseInternal().tables;
856
+ }
857
+ function getTable(name) {
858
+ return getMooseInternal().tables.get(name);
859
+ }
860
+ function getStreams() {
861
+ return getMooseInternal().streams;
862
+ }
863
+ function getStream(name) {
864
+ return getMooseInternal().streams.get(name);
865
+ }
866
+ function getIngestApis() {
867
+ return getMooseInternal().ingestApis;
868
+ }
869
+ function getIngestApi(name) {
870
+ return getMooseInternal().ingestApis.get(name);
871
+ }
872
+ function getApis() {
873
+ return getMooseInternal().apis;
874
+ }
875
+ function getApi(nameOrPath) {
876
+ const registry = getMooseInternal();
877
+ const directMatch = registry.apis.get(nameOrPath);
878
+ if (directMatch) {
879
+ return directMatch;
880
+ }
881
+ const versionedApis = /* @__PURE__ */ new Map();
882
+ const pathMap = /* @__PURE__ */ new Map();
883
+ registry.apis.forEach((api, key) => {
884
+ const baseName = api.name;
885
+ if (!versionedApis.has(baseName)) {
886
+ versionedApis.set(baseName, []);
887
+ }
888
+ versionedApis.get(baseName).push(api);
889
+ if (api.config.path) {
890
+ pathMap.set(api.config.path, api);
891
+ }
892
+ });
893
+ const candidates = versionedApis.get(nameOrPath);
894
+ if (candidates && candidates.length === 1) {
895
+ return candidates[0];
896
+ }
897
+ return pathMap.get(nameOrPath);
898
+ }
899
+ function getSqlResources() {
900
+ return getMooseInternal().sqlResources;
901
+ }
902
+ function getSqlResource(name) {
903
+ return getMooseInternal().sqlResources.get(name);
904
+ }
905
+ function getWorkflows() {
906
+ return getMooseInternal().workflows;
907
+ }
908
+ function getWorkflow(name) {
909
+ return getMooseInternal().workflows.get(name);
910
+ }
911
+ function getWebApps() {
912
+ return getMooseInternal().webApps;
913
+ }
914
+ function getWebApp(name) {
915
+ return getMooseInternal().webApps.get(name);
916
+ }
917
+ function getMaterializedViews() {
918
+ return getMooseInternal().materializedViews;
919
+ }
920
+ function getMaterializedView(name) {
921
+ return getMooseInternal().materializedViews.get(name);
922
+ }
923
+ function getViews() {
924
+ return getMooseInternal().views;
925
+ }
926
+ function getView(name) {
927
+ return getMooseInternal().views.get(name);
928
+ }
929
+ function getSelectRowPolicies() {
930
+ return getMooseInternal().selectRowPolicies;
931
+ }
932
+ function getSelectRowPolicy(name) {
933
+ return getMooseInternal().selectRowPolicies.get(name);
934
+ }
935
+
936
+ // src/consumption-apis/standalone.ts
937
+ var import_node_async_hooks = require("async_hooks");
938
+ var requestContextStorage = new import_node_async_hooks.AsyncLocalStorage();
939
+
842
940
  // src/utilities/dataParser.ts
843
941
  var import_csv_parse = require("csv-parse");
844
942
  var CSV_DELIMITERS = {
@@ -1030,7 +1128,8 @@ function createRegistryFrom(existing) {
1030
1128
  workflows: toTrackingMap(existing?.workflows),
1031
1129
  webApps: toTrackingMap(existing?.webApps),
1032
1130
  materializedViews: toTrackingMap(existing?.materializedViews),
1033
- views: toTrackingMap(existing?.views)
1131
+ views: toTrackingMap(existing?.views),
1132
+ selectRowPolicies: toTrackingMap(existing?.selectRowPolicies)
1034
1133
  };
1035
1134
  }
1036
1135
  var moose_internal = {
@@ -1066,7 +1165,11 @@ var moose_internal = {
1066
1165
  void 0,
1067
1166
  markRegistryMutated
1068
1167
  ),
1069
- views: new MutationTrackingMap(void 0, markRegistryMutated)
1168
+ views: new MutationTrackingMap(void 0, markRegistryMutated),
1169
+ selectRowPolicies: new MutationTrackingMap(
1170
+ void 0,
1171
+ markRegistryMutated
1172
+ )
1070
1173
  };
1071
1174
  var defaultRetentionPeriod = 60 * 60 * 24 * 7;
1072
1175
  var initializeMooseInternalRegistry = () => {
@@ -1253,10 +1356,7 @@ var OlapTable = class extends TypedBase {
1253
1356
  }
1254
1357
  tables.set(registryKey, this);
1255
1358
  }
1256
- /**
1257
- * Generates the versioned table name following Moose's naming convention
1258
- * Format: {tableName}_{version_with_dots_replaced_by_underscores}
1259
- */
1359
+ /** @internal Returns the versioned ClickHouse table name (e.g., "events_1_0_0") */
1260
1360
  generateTableName() {
1261
1361
  if (this._cachedTableName) {
1262
1362
  return this._cachedTableName;
@@ -2965,6 +3065,47 @@ var View = class {
2965
3065
  }
2966
3066
  };
2967
3067
 
3068
+ // src/dmv2/sdk/selectRowPolicy.ts
3069
+ var SelectRowPolicy = class {
3070
+ /** @internal */
3071
+ kind = "SelectRowPolicy";
3072
+ /** The name of the row policy */
3073
+ name;
3074
+ /** The policy configuration */
3075
+ config;
3076
+ constructor(name, config) {
3077
+ if (!name.trim()) {
3078
+ throw new Error("SelectRowPolicy name must not be empty");
3079
+ }
3080
+ if (!config.tables.length) {
3081
+ throw new Error(`SelectRowPolicy '${name}': tables must not be empty`);
3082
+ }
3083
+ if (!config.column.trim()) {
3084
+ throw new Error(`SelectRowPolicy '${name}': column must not be empty`);
3085
+ }
3086
+ if (!config.claim.trim()) {
3087
+ throw new Error(`SelectRowPolicy '${name}': claim must not be empty`);
3088
+ }
3089
+ this.name = name;
3090
+ this.config = Object.freeze({
3091
+ ...config,
3092
+ tables: Object.freeze([...config.tables])
3093
+ });
3094
+ const selectRowPolicies = getMooseInternal().selectRowPolicies;
3095
+ if (!isClientOnlyMode() && selectRowPolicies.has(this.name)) {
3096
+ throw new Error(`SelectRowPolicy with name ${this.name} already exists`);
3097
+ }
3098
+ selectRowPolicies.set(this.name, this);
3099
+ }
3100
+ /** Resolved table references for serialization */
3101
+ get tableRefs() {
3102
+ return this.config.tables.map((t) => ({
3103
+ name: t.generateTableName(),
3104
+ ...t.config.database ? { database: t.config.database } : {}
3105
+ }));
3106
+ }
3107
+ };
3108
+
2968
3109
  // src/dmv2/sdk/lifeCycle.ts
2969
3110
  var LifeCycle = /* @__PURE__ */ ((LifeCycle2) => {
2970
3111
  LifeCycle2["FULLY_MANAGED"] = "FULLY_MANAGED";
@@ -3099,83 +3240,6 @@ Examples:
3099
3240
  return this._rawApp;
3100
3241
  }
3101
3242
  };
3102
-
3103
- // src/dmv2/registry.ts
3104
- function getTables() {
3105
- return getMooseInternal().tables;
3106
- }
3107
- function getTable(name) {
3108
- return getMooseInternal().tables.get(name);
3109
- }
3110
- function getStreams() {
3111
- return getMooseInternal().streams;
3112
- }
3113
- function getStream(name) {
3114
- return getMooseInternal().streams.get(name);
3115
- }
3116
- function getIngestApis() {
3117
- return getMooseInternal().ingestApis;
3118
- }
3119
- function getIngestApi(name) {
3120
- return getMooseInternal().ingestApis.get(name);
3121
- }
3122
- function getApis() {
3123
- return getMooseInternal().apis;
3124
- }
3125
- function getApi(nameOrPath) {
3126
- const registry = getMooseInternal();
3127
- const directMatch = registry.apis.get(nameOrPath);
3128
- if (directMatch) {
3129
- return directMatch;
3130
- }
3131
- const versionedApis = /* @__PURE__ */ new Map();
3132
- const pathMap = /* @__PURE__ */ new Map();
3133
- registry.apis.forEach((api, key) => {
3134
- const baseName = api.name;
3135
- if (!versionedApis.has(baseName)) {
3136
- versionedApis.set(baseName, []);
3137
- }
3138
- versionedApis.get(baseName).push(api);
3139
- if (api.config.path) {
3140
- pathMap.set(api.config.path, api);
3141
- }
3142
- });
3143
- const candidates = versionedApis.get(nameOrPath);
3144
- if (candidates && candidates.length === 1) {
3145
- return candidates[0];
3146
- }
3147
- return pathMap.get(nameOrPath);
3148
- }
3149
- function getSqlResources() {
3150
- return getMooseInternal().sqlResources;
3151
- }
3152
- function getSqlResource(name) {
3153
- return getMooseInternal().sqlResources.get(name);
3154
- }
3155
- function getWorkflows() {
3156
- return getMooseInternal().workflows;
3157
- }
3158
- function getWorkflow(name) {
3159
- return getMooseInternal().workflows.get(name);
3160
- }
3161
- function getWebApps() {
3162
- return getMooseInternal().webApps;
3163
- }
3164
- function getWebApp(name) {
3165
- return getMooseInternal().webApps.get(name);
3166
- }
3167
- function getMaterializedViews() {
3168
- return getMooseInternal().materializedViews;
3169
- }
3170
- function getMaterializedView(name) {
3171
- return getMooseInternal().materializedViews.get(name);
3172
- }
3173
- function getViews() {
3174
- return getMooseInternal().views;
3175
- }
3176
- function getView(name) {
3177
- return getMooseInternal().views.get(name);
3178
- }
3179
3243
  // Annotate the CommonJS export names for ESM import in node:
3180
3244
  0 && (module.exports = {
3181
3245
  Api,
@@ -3188,6 +3252,7 @@ function getView(name) {
3188
3252
  LifeCycle,
3189
3253
  MaterializedView,
3190
3254
  OlapTable,
3255
+ SelectRowPolicy,
3191
3256
  SqlResource,
3192
3257
  Stream,
3193
3258
  Task,
@@ -3200,6 +3265,8 @@ function getView(name) {
3200
3265
  getIngestApis,
3201
3266
  getMaterializedView,
3202
3267
  getMaterializedViews,
3268
+ getSelectRowPolicies,
3269
+ getSelectRowPolicy,
3203
3270
  getSqlResource,
3204
3271
  getSqlResources,
3205
3272
  getStream,