@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.
@@ -1134,6 +1134,7 @@ var dlqColumns = [
1134
1134
  ttl: null,
1135
1135
  codec: null,
1136
1136
  materialized: null,
1137
+ alias: null,
1137
1138
  comment: null
1138
1139
  },
1139
1140
  {
@@ -1147,6 +1148,7 @@ var dlqColumns = [
1147
1148
  ttl: null,
1148
1149
  codec: null,
1149
1150
  materialized: null,
1151
+ alias: null,
1150
1152
  comment: null
1151
1153
  },
1152
1154
  {
@@ -1160,6 +1162,7 @@ var dlqColumns = [
1160
1162
  ttl: null,
1161
1163
  codec: null,
1162
1164
  materialized: null,
1165
+ alias: null,
1163
1166
  comment: null
1164
1167
  },
1165
1168
  {
@@ -1173,6 +1176,7 @@ var dlqColumns = [
1173
1176
  ttl: null,
1174
1177
  codec: null,
1175
1178
  materialized: null,
1179
+ alias: null,
1176
1180
  comment: null
1177
1181
  },
1178
1182
  {
@@ -1186,6 +1190,7 @@ var dlqColumns = [
1186
1190
  ttl: null,
1187
1191
  codec: null,
1188
1192
  materialized: null,
1193
+ alias: null,
1189
1194
  comment: null
1190
1195
  }
1191
1196
  ];
@@ -1197,13 +1202,15 @@ var OlapTable2 = class extends TypedBase {
1197
1202
  name;
1198
1203
  /** @internal */
1199
1204
  kind = "OlapTable";
1205
+ /** @internal Typia validators for Insertable<T> — used during insert validation */
1206
+ insertValidators;
1200
1207
  /** @internal Memoized ClickHouse client for reusing connections across insert calls */
1201
1208
  _memoizedClient;
1202
1209
  /** @internal Hash of the configuration used to create the memoized client */
1203
1210
  _configHash;
1204
1211
  /** @internal Cached table name to avoid repeated generation */
1205
1212
  _cachedTableName;
1206
- constructor(name, config, schema, columns, validators) {
1213
+ constructor(name, config, schema, columns, validators, insertValidators) {
1207
1214
  const resolvedConfig = config ? "engine" in config ? config : { ...config, engine: "MergeTree" /* MergeTree */ } : { engine: "MergeTree" /* MergeTree */ };
1208
1215
  const hasFields = Array.isArray(resolvedConfig.orderByFields) && resolvedConfig.orderByFields.length > 0;
1209
1216
  const hasExpr = typeof resolvedConfig.orderByExpression === "string" && resolvedConfig.orderByExpression.length > 0;
@@ -1221,6 +1228,7 @@ var OlapTable2 = class extends TypedBase {
1221
1228
  );
1222
1229
  }
1223
1230
  super(name, resolvedConfig, schema, columns, validators);
1231
+ this.insertValidators = insertValidators;
1224
1232
  this.name = name;
1225
1233
  const tables = getMooseInternal().tables;
1226
1234
  const registryKey = this.config.version ? `${name}_${this.config.version}` : name;
@@ -1364,6 +1372,54 @@ var OlapTable2 = class extends TypedBase {
1364
1372
  }
1365
1373
  throw new Error("No typia validator found");
1366
1374
  }
1375
+ /**
1376
+ * Validates records for insert using Insertable<T> validators when available.
1377
+ * Falls back to the full T validators if insert validators weren't generated.
1378
+ * @private
1379
+ */
1380
+ async validateInsertRecords(data) {
1381
+ const iv = this.insertValidators;
1382
+ if (!iv?.is) {
1383
+ return this.validateRecords(data);
1384
+ }
1385
+ const valid = [];
1386
+ const invalid = [];
1387
+ for (let i = 0; i < data.length; i++) {
1388
+ const record = data[i];
1389
+ try {
1390
+ if (iv.is(record)) {
1391
+ valid.push(this.mapToClickhouseRecord(record));
1392
+ } else if (iv.validate) {
1393
+ const result = iv.validate(record);
1394
+ if (result.success) {
1395
+ valid.push(this.mapToClickhouseRecord(record));
1396
+ } else {
1397
+ invalid.push({
1398
+ record,
1399
+ error: result.errors?.map((e) => String(e)).join(", ") || "Validation failed",
1400
+ index: i,
1401
+ path: "root"
1402
+ });
1403
+ }
1404
+ } else {
1405
+ invalid.push({
1406
+ record,
1407
+ error: "Validation failed",
1408
+ index: i,
1409
+ path: "root"
1410
+ });
1411
+ }
1412
+ } catch (error) {
1413
+ invalid.push({
1414
+ record,
1415
+ error: error instanceof Error ? error.message : String(error),
1416
+ index: i,
1417
+ path: "root"
1418
+ });
1419
+ }
1420
+ }
1421
+ return { valid, invalid, total: data.length };
1422
+ }
1367
1423
  /**
1368
1424
  * Validates an array of records with comprehensive error reporting.
1369
1425
  * Uses the most appropriate validation method available (typia or basic).
@@ -1512,7 +1568,9 @@ var OlapTable2 = class extends TypedBase {
1512
1568
  return { validatedData: data, validationErrors: [] };
1513
1569
  }
1514
1570
  try {
1515
- const validationResult = await this.validateRecords(data);
1571
+ const validationResult = await this.validateInsertRecords(
1572
+ data
1573
+ );
1516
1574
  const validatedData = validationResult.valid;
1517
1575
  const validationErrors = validationResult.invalid;
1518
1576
  if (validationErrors.length > 0) {
@@ -1817,8 +1875,9 @@ var OlapTable2 = class extends TypedBase {
1817
1875
  * ```
1818
1876
  */
1819
1877
  async insert(data, options) {
1820
- const { isStream, strategy, shouldValidate } = this.validateInsertParameters(data, options);
1821
- const emptyResult = this.handleEmptyData(data, isStream);
1878
+ const rawData = data;
1879
+ const { isStream, strategy, shouldValidate } = this.validateInsertParameters(rawData, options);
1880
+ const emptyResult = this.handleEmptyData(rawData, isStream);
1822
1881
  if (emptyResult) {
1823
1882
  return emptyResult;
1824
1883
  }
@@ -1826,7 +1885,7 @@ var OlapTable2 = class extends TypedBase {
1826
1885
  let validationErrors = [];
1827
1886
  if (!isStream && shouldValidate) {
1828
1887
  const validationResult = await this.performPreInsertionValidation(
1829
- data,
1888
+ rawData,
1830
1889
  shouldValidate,
1831
1890
  strategy,
1832
1891
  options
@@ -1834,14 +1893,14 @@ var OlapTable2 = class extends TypedBase {
1834
1893
  validatedData = validationResult.validatedData;
1835
1894
  validationErrors = validationResult.validationErrors;
1836
1895
  } else {
1837
- validatedData = isStream ? [] : data;
1896
+ validatedData = isStream ? [] : rawData;
1838
1897
  }
1839
1898
  const { client } = await this.getMemoizedClient();
1840
1899
  const tableName = this.generateTableName();
1841
1900
  try {
1842
1901
  const insertOptions = this.prepareInsertOptions(
1843
1902
  tableName,
1844
- data,
1903
+ rawData,
1845
1904
  validatedData,
1846
1905
  isStream,
1847
1906
  strategy,
@@ -1849,7 +1908,7 @@ var OlapTable2 = class extends TypedBase {
1849
1908
  );
1850
1909
  await client.insert(insertOptions);
1851
1910
  return this.createSuccessResult(
1852
- data,
1911
+ rawData,
1853
1912
  validatedData,
1854
1913
  validationErrors,
1855
1914
  isStream,
@@ -1861,7 +1920,7 @@ var OlapTable2 = class extends TypedBase {
1861
1920
  batchError,
1862
1921
  strategy,
1863
1922
  tableName,
1864
- data,
1923
+ rawData,
1865
1924
  validatedData,
1866
1925
  validationErrors,
1867
1926
  isStream,