@514labs/moose-lib 0.6.514 → 0.6.515
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/browserCompatible.d.mts +2 -2
- package/dist/browserCompatible.d.ts +2 -2
- package/dist/browserCompatible.js +71 -57
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +71 -57
- package/dist/browserCompatible.mjs.map +1 -1
- package/dist/dmv2/index.d.mts +2 -2
- package/dist/dmv2/index.d.ts +2 -2
- package/dist/dmv2/index.js +67 -53
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +67 -53
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/{index-BCTJXoD8.d.mts → index-7uxZbwmY.d.ts} +3 -2
- package/dist/{index-BOIsE8xN.d.ts → index-k_kpRxE3.d.mts} +3 -2
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +257 -245
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +257 -245
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +30 -11
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +30 -11
- package/dist/moose-runner.mjs.map +1 -1
- package/dist/testing/index.d.mts +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.js +5 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/index.mjs +5 -1
- package/dist/testing/index.mjs.map +1 -1
- package/dist/{view-CJKyTLjp.d.mts → view-BCWJcLF6.d.mts} +23 -4
- package/dist/{view-CJKyTLjp.d.ts → view-BCWJcLF6.d.ts} +23 -4
- package/package.json +1 -1
package/dist/dmv2/index.mjs
CHANGED
|
@@ -700,7 +700,11 @@ var Sql = class _Sql {
|
|
|
700
700
|
}
|
|
701
701
|
this.strings[pos] += rawString;
|
|
702
702
|
} else if (isView(child)) {
|
|
703
|
-
|
|
703
|
+
if (child.database) {
|
|
704
|
+
this.strings[pos] += `\`${child.database}\`.\`${child.name}\``;
|
|
705
|
+
} else {
|
|
706
|
+
this.strings[pos] += `\`${child.name}\``;
|
|
707
|
+
}
|
|
704
708
|
this.strings[pos] += rawString;
|
|
705
709
|
} else {
|
|
706
710
|
this.values[pos++] = child;
|
|
@@ -803,6 +807,65 @@ import { createClient as createClient2 } from "redis";
|
|
|
803
807
|
// src/consumption-apis/standalone.ts
|
|
804
808
|
init_commons();
|
|
805
809
|
|
|
810
|
+
// src/dmv2/sdk/tableReferenceUtils.ts
|
|
811
|
+
function formatTableReference(table) {
|
|
812
|
+
const database = table instanceof OlapTable ? table.config.database : table.database;
|
|
813
|
+
const deployedName = table instanceof OlapTable ? table.generateTableName() : table.name;
|
|
814
|
+
if (database) {
|
|
815
|
+
return `\`${database}\`.\`${deployedName}\``;
|
|
816
|
+
}
|
|
817
|
+
return `\`${deployedName}\``;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
// src/dmv2/sdk/view.ts
|
|
821
|
+
function viewRegistryKey(database, name) {
|
|
822
|
+
return database ? `${database}::${name}` : name;
|
|
823
|
+
}
|
|
824
|
+
var View = class {
|
|
825
|
+
/** @internal */
|
|
826
|
+
kind = "View";
|
|
827
|
+
/** The name of the view */
|
|
828
|
+
name;
|
|
829
|
+
/** Optional database where the view is created. When set, the view is created as `database`.`name` in ClickHouse. */
|
|
830
|
+
database;
|
|
831
|
+
/** The SELECT SQL statement that defines the view */
|
|
832
|
+
selectSql;
|
|
833
|
+
/** Names of source tables/views that the SELECT reads from */
|
|
834
|
+
sourceTables;
|
|
835
|
+
/** Optional metadata for the view */
|
|
836
|
+
metadata;
|
|
837
|
+
constructor(name, configOrSelectStatement, baseTables, metadata) {
|
|
838
|
+
const config = typeof configOrSelectStatement === "object" && configOrSelectStatement !== null && "selectStatement" in configOrSelectStatement && "baseTables" in configOrSelectStatement ? configOrSelectStatement : {
|
|
839
|
+
selectStatement: configOrSelectStatement,
|
|
840
|
+
baseTables: baseTables ?? [],
|
|
841
|
+
metadata
|
|
842
|
+
};
|
|
843
|
+
let selectStatement = config.selectStatement;
|
|
844
|
+
if (typeof selectStatement !== "string") {
|
|
845
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
846
|
+
}
|
|
847
|
+
this.name = name;
|
|
848
|
+
this.database = config.database;
|
|
849
|
+
this.selectSql = selectStatement;
|
|
850
|
+
this.sourceTables = config.baseTables.map((t) => formatTableReference(t));
|
|
851
|
+
this.metadata = config.metadata ? { ...config.metadata } : {};
|
|
852
|
+
if (!this.metadata.source) {
|
|
853
|
+
const stack = new Error().stack;
|
|
854
|
+
const sourceInfo = getSourceFileFromStack(stack);
|
|
855
|
+
if (sourceInfo) {
|
|
856
|
+
this.metadata.source = { file: sourceInfo };
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
const views = getMooseInternal().views;
|
|
860
|
+
const registryKey = viewRegistryKey(this.database, this.name);
|
|
861
|
+
if (!isClientOnlyMode() && views.has(registryKey)) {
|
|
862
|
+
const qualifiedName = this.database ? `${this.database}.${this.name}` : this.name;
|
|
863
|
+
throw new Error(`View with name ${qualifiedName} already exists`);
|
|
864
|
+
}
|
|
865
|
+
views.set(registryKey, this);
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
|
|
806
869
|
// src/dmv2/registry.ts
|
|
807
870
|
function getTables() {
|
|
808
871
|
return getMooseInternal().tables;
|
|
@@ -876,8 +939,9 @@ function getMaterializedView(name) {
|
|
|
876
939
|
function getViews() {
|
|
877
940
|
return getMooseInternal().views;
|
|
878
941
|
}
|
|
879
|
-
function getView(name) {
|
|
880
|
-
|
|
942
|
+
function getView(name, database) {
|
|
943
|
+
const key = viewRegistryKey(database, name);
|
|
944
|
+
return getMooseInternal().views.get(key);
|
|
881
945
|
}
|
|
882
946
|
function getSelectRowPolicies() {
|
|
883
947
|
return getMooseInternal().selectRowPolicies;
|
|
@@ -2828,56 +2892,6 @@ var ETLPipeline = class {
|
|
|
2828
2892
|
}
|
|
2829
2893
|
};
|
|
2830
2894
|
|
|
2831
|
-
// src/dmv2/sdk/view.ts
|
|
2832
|
-
function formatTableReference(table) {
|
|
2833
|
-
const database = table instanceof OlapTable ? table.config.database : void 0;
|
|
2834
|
-
const deployedName = table instanceof OlapTable ? table.generateTableName() : table.name;
|
|
2835
|
-
if (database) {
|
|
2836
|
-
return `\`${database}\`.\`${deployedName}\``;
|
|
2837
|
-
}
|
|
2838
|
-
return `\`${deployedName}\``;
|
|
2839
|
-
}
|
|
2840
|
-
var View = class {
|
|
2841
|
-
/** @internal */
|
|
2842
|
-
kind = "View";
|
|
2843
|
-
/** The name of the view */
|
|
2844
|
-
name;
|
|
2845
|
-
/** The SELECT SQL statement that defines the view */
|
|
2846
|
-
selectSql;
|
|
2847
|
-
/** Names of source tables/views that the SELECT reads from */
|
|
2848
|
-
sourceTables;
|
|
2849
|
-
/** Optional metadata for the view */
|
|
2850
|
-
metadata;
|
|
2851
|
-
/**
|
|
2852
|
-
* Creates a new View instance.
|
|
2853
|
-
* @param name The name of the view to be created.
|
|
2854
|
-
* @param selectStatement The SQL SELECT statement that defines the view's logic.
|
|
2855
|
-
* @param baseTables An array of OlapTable or View objects that the `selectStatement` reads from. Used for dependency tracking.
|
|
2856
|
-
* @param metadata Optional metadata for the view (e.g., description, source file).
|
|
2857
|
-
*/
|
|
2858
|
-
constructor(name, selectStatement, baseTables, metadata) {
|
|
2859
|
-
if (typeof selectStatement !== "string") {
|
|
2860
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2861
|
-
}
|
|
2862
|
-
this.name = name;
|
|
2863
|
-
this.selectSql = selectStatement;
|
|
2864
|
-
this.sourceTables = baseTables.map((t) => formatTableReference(t));
|
|
2865
|
-
this.metadata = metadata ? { ...metadata } : {};
|
|
2866
|
-
if (!this.metadata.source) {
|
|
2867
|
-
const stack = new Error().stack;
|
|
2868
|
-
const sourceInfo = getSourceFileFromStack(stack);
|
|
2869
|
-
if (sourceInfo) {
|
|
2870
|
-
this.metadata.source = { file: sourceInfo };
|
|
2871
|
-
}
|
|
2872
|
-
}
|
|
2873
|
-
const views = getMooseInternal().views;
|
|
2874
|
-
if (!isClientOnlyMode() && views.has(this.name)) {
|
|
2875
|
-
throw new Error(`View with name ${this.name} already exists`);
|
|
2876
|
-
}
|
|
2877
|
-
views.set(this.name, this);
|
|
2878
|
-
}
|
|
2879
|
-
};
|
|
2880
|
-
|
|
2881
2895
|
// src/dmv2/sdk/materializedView.ts
|
|
2882
2896
|
var requireTargetTableName = (tableName) => {
|
|
2883
2897
|
if (typeof tableName === "string") {
|