@514labs/moose-lib 0.6.446 → 0.6.447
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 +1 -1
- package/dist/browserCompatible.d.ts +1 -1
- package/dist/browserCompatible.js +68 -9
- package/dist/browserCompatible.js.map +1 -1
- package/dist/browserCompatible.mjs +68 -9
- package/dist/browserCompatible.mjs.map +1 -1
- package/dist/compilerPlugin.js +91 -7
- package/dist/compilerPlugin.js.map +1 -1
- package/dist/compilerPlugin.mjs +91 -7
- package/dist/compilerPlugin.mjs.map +1 -1
- package/dist/dataModels/toDataModels.js.map +1 -1
- package/dist/dataModels/toDataModels.mjs.map +1 -1
- package/dist/dmv2/index.d.mts +1 -1
- package/dist/dmv2/index.d.ts +1 -1
- package/dist/dmv2/index.js +68 -9
- package/dist/dmv2/index.js.map +1 -1
- package/dist/dmv2/index.mjs +68 -9
- package/dist/dmv2/index.mjs.map +1 -1
- package/dist/{index-D22Yb8pY.d.mts → index-FbIy0gSU.d.mts} +45 -3
- package/dist/{index-D22Yb8pY.d.ts → index-FbIy0gSU.d.ts} +45 -3
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +73 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -10
- package/dist/index.mjs.map +1 -1
- package/dist/moose-runner.js +5 -1
- package/dist/moose-runner.js.map +1 -1
- package/dist/moose-runner.mjs +5 -1
- package/dist/moose-runner.mjs.map +1 -1
- package/package.json +1 -1
package/dist/dmv2/index.mjs
CHANGED
|
@@ -1100,6 +1100,7 @@ var dlqColumns = [
|
|
|
1100
1100
|
ttl: null,
|
|
1101
1101
|
codec: null,
|
|
1102
1102
|
materialized: null,
|
|
1103
|
+
alias: null,
|
|
1103
1104
|
comment: null
|
|
1104
1105
|
},
|
|
1105
1106
|
{
|
|
@@ -1113,6 +1114,7 @@ var dlqColumns = [
|
|
|
1113
1114
|
ttl: null,
|
|
1114
1115
|
codec: null,
|
|
1115
1116
|
materialized: null,
|
|
1117
|
+
alias: null,
|
|
1116
1118
|
comment: null
|
|
1117
1119
|
},
|
|
1118
1120
|
{
|
|
@@ -1126,6 +1128,7 @@ var dlqColumns = [
|
|
|
1126
1128
|
ttl: null,
|
|
1127
1129
|
codec: null,
|
|
1128
1130
|
materialized: null,
|
|
1131
|
+
alias: null,
|
|
1129
1132
|
comment: null
|
|
1130
1133
|
},
|
|
1131
1134
|
{
|
|
@@ -1139,6 +1142,7 @@ var dlqColumns = [
|
|
|
1139
1142
|
ttl: null,
|
|
1140
1143
|
codec: null,
|
|
1141
1144
|
materialized: null,
|
|
1145
|
+
alias: null,
|
|
1142
1146
|
comment: null
|
|
1143
1147
|
},
|
|
1144
1148
|
{
|
|
@@ -1152,6 +1156,7 @@ var dlqColumns = [
|
|
|
1152
1156
|
ttl: null,
|
|
1153
1157
|
codec: null,
|
|
1154
1158
|
materialized: null,
|
|
1159
|
+
alias: null,
|
|
1155
1160
|
comment: null
|
|
1156
1161
|
}
|
|
1157
1162
|
];
|
|
@@ -1163,13 +1168,15 @@ var OlapTable = class extends TypedBase {
|
|
|
1163
1168
|
name;
|
|
1164
1169
|
/** @internal */
|
|
1165
1170
|
kind = "OlapTable";
|
|
1171
|
+
/** @internal Typia validators for Insertable<T> — used during insert validation */
|
|
1172
|
+
insertValidators;
|
|
1166
1173
|
/** @internal Memoized ClickHouse client for reusing connections across insert calls */
|
|
1167
1174
|
_memoizedClient;
|
|
1168
1175
|
/** @internal Hash of the configuration used to create the memoized client */
|
|
1169
1176
|
_configHash;
|
|
1170
1177
|
/** @internal Cached table name to avoid repeated generation */
|
|
1171
1178
|
_cachedTableName;
|
|
1172
|
-
constructor(name, config, schema, columns, validators) {
|
|
1179
|
+
constructor(name, config, schema, columns, validators, insertValidators) {
|
|
1173
1180
|
const resolvedConfig = config ? "engine" in config ? config : { ...config, engine: "MergeTree" /* MergeTree */ } : { engine: "MergeTree" /* MergeTree */ };
|
|
1174
1181
|
const hasFields = Array.isArray(resolvedConfig.orderByFields) && resolvedConfig.orderByFields.length > 0;
|
|
1175
1182
|
const hasExpr = typeof resolvedConfig.orderByExpression === "string" && resolvedConfig.orderByExpression.length > 0;
|
|
@@ -1187,6 +1194,7 @@ var OlapTable = class extends TypedBase {
|
|
|
1187
1194
|
);
|
|
1188
1195
|
}
|
|
1189
1196
|
super(name, resolvedConfig, schema, columns, validators);
|
|
1197
|
+
this.insertValidators = insertValidators;
|
|
1190
1198
|
this.name = name;
|
|
1191
1199
|
const tables = getMooseInternal().tables;
|
|
1192
1200
|
const registryKey = this.config.version ? `${name}_${this.config.version}` : name;
|
|
@@ -1330,6 +1338,54 @@ var OlapTable = class extends TypedBase {
|
|
|
1330
1338
|
}
|
|
1331
1339
|
throw new Error("No typia validator found");
|
|
1332
1340
|
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Validates records for insert using Insertable<T> validators when available.
|
|
1343
|
+
* Falls back to the full T validators if insert validators weren't generated.
|
|
1344
|
+
* @private
|
|
1345
|
+
*/
|
|
1346
|
+
async validateInsertRecords(data) {
|
|
1347
|
+
const iv = this.insertValidators;
|
|
1348
|
+
if (!iv?.is) {
|
|
1349
|
+
return this.validateRecords(data);
|
|
1350
|
+
}
|
|
1351
|
+
const valid = [];
|
|
1352
|
+
const invalid = [];
|
|
1353
|
+
for (let i = 0; i < data.length; i++) {
|
|
1354
|
+
const record = data[i];
|
|
1355
|
+
try {
|
|
1356
|
+
if (iv.is(record)) {
|
|
1357
|
+
valid.push(this.mapToClickhouseRecord(record));
|
|
1358
|
+
} else if (iv.validate) {
|
|
1359
|
+
const result = iv.validate(record);
|
|
1360
|
+
if (result.success) {
|
|
1361
|
+
valid.push(this.mapToClickhouseRecord(record));
|
|
1362
|
+
} else {
|
|
1363
|
+
invalid.push({
|
|
1364
|
+
record,
|
|
1365
|
+
error: result.errors?.map((e) => String(e)).join(", ") || "Validation failed",
|
|
1366
|
+
index: i,
|
|
1367
|
+
path: "root"
|
|
1368
|
+
});
|
|
1369
|
+
}
|
|
1370
|
+
} else {
|
|
1371
|
+
invalid.push({
|
|
1372
|
+
record,
|
|
1373
|
+
error: "Validation failed",
|
|
1374
|
+
index: i,
|
|
1375
|
+
path: "root"
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
} catch (error) {
|
|
1379
|
+
invalid.push({
|
|
1380
|
+
record,
|
|
1381
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1382
|
+
index: i,
|
|
1383
|
+
path: "root"
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
return { valid, invalid, total: data.length };
|
|
1388
|
+
}
|
|
1333
1389
|
/**
|
|
1334
1390
|
* Validates an array of records with comprehensive error reporting.
|
|
1335
1391
|
* Uses the most appropriate validation method available (typia or basic).
|
|
@@ -1478,7 +1534,9 @@ var OlapTable = class extends TypedBase {
|
|
|
1478
1534
|
return { validatedData: data, validationErrors: [] };
|
|
1479
1535
|
}
|
|
1480
1536
|
try {
|
|
1481
|
-
const validationResult = await this.
|
|
1537
|
+
const validationResult = await this.validateInsertRecords(
|
|
1538
|
+
data
|
|
1539
|
+
);
|
|
1482
1540
|
const validatedData = validationResult.valid;
|
|
1483
1541
|
const validationErrors = validationResult.invalid;
|
|
1484
1542
|
if (validationErrors.length > 0) {
|
|
@@ -1783,8 +1841,9 @@ var OlapTable = class extends TypedBase {
|
|
|
1783
1841
|
* ```
|
|
1784
1842
|
*/
|
|
1785
1843
|
async insert(data, options) {
|
|
1786
|
-
const
|
|
1787
|
-
const
|
|
1844
|
+
const rawData = data;
|
|
1845
|
+
const { isStream, strategy, shouldValidate } = this.validateInsertParameters(rawData, options);
|
|
1846
|
+
const emptyResult = this.handleEmptyData(rawData, isStream);
|
|
1788
1847
|
if (emptyResult) {
|
|
1789
1848
|
return emptyResult;
|
|
1790
1849
|
}
|
|
@@ -1792,7 +1851,7 @@ var OlapTable = class extends TypedBase {
|
|
|
1792
1851
|
let validationErrors = [];
|
|
1793
1852
|
if (!isStream && shouldValidate) {
|
|
1794
1853
|
const validationResult = await this.performPreInsertionValidation(
|
|
1795
|
-
|
|
1854
|
+
rawData,
|
|
1796
1855
|
shouldValidate,
|
|
1797
1856
|
strategy,
|
|
1798
1857
|
options
|
|
@@ -1800,14 +1859,14 @@ var OlapTable = class extends TypedBase {
|
|
|
1800
1859
|
validatedData = validationResult.validatedData;
|
|
1801
1860
|
validationErrors = validationResult.validationErrors;
|
|
1802
1861
|
} else {
|
|
1803
|
-
validatedData = isStream ? [] :
|
|
1862
|
+
validatedData = isStream ? [] : rawData;
|
|
1804
1863
|
}
|
|
1805
1864
|
const { client } = await this.getMemoizedClient();
|
|
1806
1865
|
const tableName = this.generateTableName();
|
|
1807
1866
|
try {
|
|
1808
1867
|
const insertOptions = this.prepareInsertOptions(
|
|
1809
1868
|
tableName,
|
|
1810
|
-
|
|
1869
|
+
rawData,
|
|
1811
1870
|
validatedData,
|
|
1812
1871
|
isStream,
|
|
1813
1872
|
strategy,
|
|
@@ -1815,7 +1874,7 @@ var OlapTable = class extends TypedBase {
|
|
|
1815
1874
|
);
|
|
1816
1875
|
await client.insert(insertOptions);
|
|
1817
1876
|
return this.createSuccessResult(
|
|
1818
|
-
|
|
1877
|
+
rawData,
|
|
1819
1878
|
validatedData,
|
|
1820
1879
|
validationErrors,
|
|
1821
1880
|
isStream,
|
|
@@ -1827,7 +1886,7 @@ var OlapTable = class extends TypedBase {
|
|
|
1827
1886
|
batchError,
|
|
1828
1887
|
strategy,
|
|
1829
1888
|
tableName,
|
|
1830
|
-
|
|
1889
|
+
rawData,
|
|
1831
1890
|
validatedData,
|
|
1832
1891
|
validationErrors,
|
|
1833
1892
|
isStream,
|