@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
|
@@ -710,7 +710,11 @@ var Sql = class _Sql {
|
|
|
710
710
|
}
|
|
711
711
|
this.strings[pos] += rawString;
|
|
712
712
|
} else if (isView(child)) {
|
|
713
|
-
|
|
713
|
+
if (child.database) {
|
|
714
|
+
this.strings[pos] += `\`${child.database}\`.\`${child.name}\``;
|
|
715
|
+
} else {
|
|
716
|
+
this.strings[pos] += `\`${child.name}\``;
|
|
717
|
+
}
|
|
714
718
|
this.strings[pos] += rawString;
|
|
715
719
|
} else {
|
|
716
720
|
this.values[pos++] = child;
|
|
@@ -837,6 +841,65 @@ import { createClient as createClient2 } from "redis";
|
|
|
837
841
|
// src/consumption-apis/standalone.ts
|
|
838
842
|
init_commons();
|
|
839
843
|
|
|
844
|
+
// src/dmv2/sdk/tableReferenceUtils.ts
|
|
845
|
+
function formatTableReference(table) {
|
|
846
|
+
const database = table instanceof OlapTable ? table.config.database : table.database;
|
|
847
|
+
const deployedName = table instanceof OlapTable ? table.generateTableName() : table.name;
|
|
848
|
+
if (database) {
|
|
849
|
+
return `\`${database}\`.\`${deployedName}\``;
|
|
850
|
+
}
|
|
851
|
+
return `\`${deployedName}\``;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
// src/dmv2/sdk/view.ts
|
|
855
|
+
function viewRegistryKey(database, name) {
|
|
856
|
+
return database ? `${database}::${name}` : name;
|
|
857
|
+
}
|
|
858
|
+
var View = class {
|
|
859
|
+
/** @internal */
|
|
860
|
+
kind = "View";
|
|
861
|
+
/** The name of the view */
|
|
862
|
+
name;
|
|
863
|
+
/** Optional database where the view is created. When set, the view is created as `database`.`name` in ClickHouse. */
|
|
864
|
+
database;
|
|
865
|
+
/** The SELECT SQL statement that defines the view */
|
|
866
|
+
selectSql;
|
|
867
|
+
/** Names of source tables/views that the SELECT reads from */
|
|
868
|
+
sourceTables;
|
|
869
|
+
/** Optional metadata for the view */
|
|
870
|
+
metadata;
|
|
871
|
+
constructor(name, configOrSelectStatement, baseTables, metadata) {
|
|
872
|
+
const config = typeof configOrSelectStatement === "object" && configOrSelectStatement !== null && "selectStatement" in configOrSelectStatement && "baseTables" in configOrSelectStatement ? configOrSelectStatement : {
|
|
873
|
+
selectStatement: configOrSelectStatement,
|
|
874
|
+
baseTables: baseTables ?? [],
|
|
875
|
+
metadata
|
|
876
|
+
};
|
|
877
|
+
let selectStatement = config.selectStatement;
|
|
878
|
+
if (typeof selectStatement !== "string") {
|
|
879
|
+
selectStatement = toStaticQuery(selectStatement);
|
|
880
|
+
}
|
|
881
|
+
this.name = name;
|
|
882
|
+
this.database = config.database;
|
|
883
|
+
this.selectSql = selectStatement;
|
|
884
|
+
this.sourceTables = config.baseTables.map((t) => formatTableReference(t));
|
|
885
|
+
this.metadata = config.metadata ? { ...config.metadata } : {};
|
|
886
|
+
if (!this.metadata.source) {
|
|
887
|
+
const stack = new Error().stack;
|
|
888
|
+
const sourceInfo = getSourceFileFromStack(stack);
|
|
889
|
+
if (sourceInfo) {
|
|
890
|
+
this.metadata.source = { file: sourceInfo };
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
const views = getMooseInternal().views;
|
|
894
|
+
const registryKey = viewRegistryKey(this.database, this.name);
|
|
895
|
+
if (!isClientOnlyMode() && views.has(registryKey)) {
|
|
896
|
+
const qualifiedName = this.database ? `${this.database}.${this.name}` : this.name;
|
|
897
|
+
throw new Error(`View with name ${qualifiedName} already exists`);
|
|
898
|
+
}
|
|
899
|
+
views.set(registryKey, this);
|
|
900
|
+
}
|
|
901
|
+
};
|
|
902
|
+
|
|
840
903
|
// src/dmv2/registry.ts
|
|
841
904
|
function getTables() {
|
|
842
905
|
return getMooseInternal().tables;
|
|
@@ -910,8 +973,9 @@ function getMaterializedView(name) {
|
|
|
910
973
|
function getViews() {
|
|
911
974
|
return getMooseInternal().views;
|
|
912
975
|
}
|
|
913
|
-
function getView(name) {
|
|
914
|
-
|
|
976
|
+
function getView(name, database) {
|
|
977
|
+
const key = viewRegistryKey(database, name);
|
|
978
|
+
return getMooseInternal().views.get(key);
|
|
915
979
|
}
|
|
916
980
|
function getSelectRowPolicies() {
|
|
917
981
|
return getMooseInternal().selectRowPolicies;
|
|
@@ -1302,7 +1366,7 @@ var dlqColumns = [
|
|
|
1302
1366
|
// src/dmv2/sdk/olapTable.ts
|
|
1303
1367
|
import { Readable } from "stream";
|
|
1304
1368
|
import { createHash as createHash2 } from "crypto";
|
|
1305
|
-
var
|
|
1369
|
+
var OlapTable = class extends TypedBase {
|
|
1306
1370
|
name;
|
|
1307
1371
|
/** @internal */
|
|
1308
1372
|
kind = "OlapTable";
|
|
@@ -2652,7 +2716,7 @@ var IngestPipeline = class extends TypedBase {
|
|
|
2652
2716
|
engine: "MergeTree" /* MergeTree */,
|
|
2653
2717
|
...config.version && { version: config.version }
|
|
2654
2718
|
};
|
|
2655
|
-
this.table = new
|
|
2719
|
+
this.table = new OlapTable(
|
|
2656
2720
|
name,
|
|
2657
2721
|
tableConfig,
|
|
2658
2722
|
this.schema,
|
|
@@ -2862,56 +2926,6 @@ var ETLPipeline = class {
|
|
|
2862
2926
|
}
|
|
2863
2927
|
};
|
|
2864
2928
|
|
|
2865
|
-
// src/dmv2/sdk/view.ts
|
|
2866
|
-
function formatTableReference(table) {
|
|
2867
|
-
const database = table instanceof OlapTable2 ? table.config.database : void 0;
|
|
2868
|
-
const deployedName = table instanceof OlapTable2 ? table.generateTableName() : table.name;
|
|
2869
|
-
if (database) {
|
|
2870
|
-
return `\`${database}\`.\`${deployedName}\``;
|
|
2871
|
-
}
|
|
2872
|
-
return `\`${deployedName}\``;
|
|
2873
|
-
}
|
|
2874
|
-
var View = class {
|
|
2875
|
-
/** @internal */
|
|
2876
|
-
kind = "View";
|
|
2877
|
-
/** The name of the view */
|
|
2878
|
-
name;
|
|
2879
|
-
/** The SELECT SQL statement that defines the view */
|
|
2880
|
-
selectSql;
|
|
2881
|
-
/** Names of source tables/views that the SELECT reads from */
|
|
2882
|
-
sourceTables;
|
|
2883
|
-
/** Optional metadata for the view */
|
|
2884
|
-
metadata;
|
|
2885
|
-
/**
|
|
2886
|
-
* Creates a new View instance.
|
|
2887
|
-
* @param name The name of the view to be created.
|
|
2888
|
-
* @param selectStatement The SQL SELECT statement that defines the view's logic.
|
|
2889
|
-
* @param baseTables An array of OlapTable or View objects that the `selectStatement` reads from. Used for dependency tracking.
|
|
2890
|
-
* @param metadata Optional metadata for the view (e.g., description, source file).
|
|
2891
|
-
*/
|
|
2892
|
-
constructor(name, selectStatement, baseTables, metadata) {
|
|
2893
|
-
if (typeof selectStatement !== "string") {
|
|
2894
|
-
selectStatement = toStaticQuery(selectStatement);
|
|
2895
|
-
}
|
|
2896
|
-
this.name = name;
|
|
2897
|
-
this.selectSql = selectStatement;
|
|
2898
|
-
this.sourceTables = baseTables.map((t) => formatTableReference(t));
|
|
2899
|
-
this.metadata = metadata ? { ...metadata } : {};
|
|
2900
|
-
if (!this.metadata.source) {
|
|
2901
|
-
const stack = new Error().stack;
|
|
2902
|
-
const sourceInfo = getSourceFileFromStack(stack);
|
|
2903
|
-
if (sourceInfo) {
|
|
2904
|
-
this.metadata.source = { file: sourceInfo };
|
|
2905
|
-
}
|
|
2906
|
-
}
|
|
2907
|
-
const views = getMooseInternal().views;
|
|
2908
|
-
if (!isClientOnlyMode() && views.has(this.name)) {
|
|
2909
|
-
throw new Error(`View with name ${this.name} already exists`);
|
|
2910
|
-
}
|
|
2911
|
-
views.set(this.name, this);
|
|
2912
|
-
}
|
|
2913
|
-
};
|
|
2914
|
-
|
|
2915
2929
|
// src/dmv2/sdk/materializedView.ts
|
|
2916
2930
|
var requireTargetTableName = (tableName) => {
|
|
2917
2931
|
if (typeof tableName === "string") {
|
|
@@ -2945,7 +2959,7 @@ var MaterializedView = class {
|
|
|
2945
2959
|
"Supply the type param T so that the schema is inserted by the compiler plugin."
|
|
2946
2960
|
);
|
|
2947
2961
|
}
|
|
2948
|
-
const targetTable = options.targetTable instanceof
|
|
2962
|
+
const targetTable = options.targetTable instanceof OlapTable ? options.targetTable : new OlapTable(
|
|
2949
2963
|
requireTargetTableName(
|
|
2950
2964
|
options.targetTable?.name ?? options.tableName
|
|
2951
2965
|
),
|
|
@@ -3223,7 +3237,7 @@ export {
|
|
|
3223
3237
|
IngestPipeline,
|
|
3224
3238
|
LifeCycle,
|
|
3225
3239
|
MaterializedView,
|
|
3226
|
-
|
|
3240
|
+
OlapTable,
|
|
3227
3241
|
SelectRowPolicy,
|
|
3228
3242
|
Sql,
|
|
3229
3243
|
SqlResource,
|