@bayoudhi/moose-lib-serverless 0.7.11 → 0.7.13

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,10 +1,11 @@
1
- export { A as Aggregated, h as Api, i as ApiConfig, ao as ApiUtil, Y as ClickHouseByteSize, a7 as ClickHouseCodec, X as ClickHouseDecimal, a3 as ClickHouseDefault, C as ClickHouseEngines, Z as ClickHouseFixedStringSize, _ as ClickHouseFloat, $ as ClickHouseInt, a0 as ClickHouseJson, a5 as ClickHouseMaterialized, a2 as ClickHouseNamedTuple, U as ClickHousePrecision, a4 as ClickHouseTTL, j as ConsumptionApi, ap as ConsumptionUtil, a8 as DateTime, a9 as DateTime64, ab as DateTime64String, aa as DateTimeString, e as DeadLetter, D as DeadLetterModel, f as DeadLetterQueue, an as Decimal, m as ETLPipeline, n as ETLPipelineConfig, E as EgressConfig, ac as FixedString, ad as Float32, ae as Float64, F as FrameworkApp, ar as IdentifierBrandedString, I as IngestApi, g as IngestConfig, k as IngestPipeline, ag as Int16, ah as Int32, ai as Int64, af as Int8, L as LifeCycle, a1 as LowCardinality, M as MaterializedView, as as NonIdentifierBrandedString, a as OlapConfig, O as OlapTable, au as RawValue, b as S3QueueTableSettings, S as SimpleAggregated, ax as Sql, l as SqlResource, av as SqlTemplateTag, c as Stream, d as StreamConfig, T as Task, ak as UInt16, al as UInt32, am as UInt64, aj as UInt8, at as Value, V as View, o as WebApp, p as WebAppConfig, q as WebAppHandler, a6 as WithDefault, W as Workflow, aC as createClickhouseParameter, 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, aB as getValueFromParameter, N as getView, P as getViews, K as getWebApp, J as getWebApps, H as getWorkflow, G as getWorkflows, aD as mapToClickHouseType, aq as quoteIdentifier, aw as sql, az as toQuery, aA as toQueryPreview, ay as toStaticQuery } from './index-DdE-_e4q';
1
+ export { A as Aggregated, f as Api, g as ApiConfig, R as ApiUtil, C as ConsumptionApi, U as ConsumptionUtil, c as DeadLetter, D as DeadLetterModel, d as DeadLetterQueue, l as ETLPipeline, m as ETLPipelineConfig, E as EgressConfig, F as FrameworkApp, I as IngestApi, e as IngestConfig, h as IngestPipeline, M as MaterializedView, j as SelectRowPolicy, k as SelectRowPolicyConfig, S as SimpleAggregated, i as SqlResource, a as Stream, b as StreamConfig, T as Task, n as WebApp, o as WebAppConfig, p as WebAppHandler, W as Workflow, x as getApi, w as getApis, v as getIngestApi, u as getIngestApis, N as getMaterializedView, O as getMaterializedViews, P as getSelectRowPolicies, Q as getSelectRowPolicy, z as getSqlResource, y as getSqlResources, t as getStream, s as getStreams, r as getTable, q as getTables, K as getView, L as getViews, J as getWebApp, H as getWebApps, G as getWorkflow, B as getWorkflows } from './index-Cs6mRtl7';
2
+ export { n as ClickHouseAlias, d as ClickHouseByteSize, o as ClickHouseCodec, c as ClickHouseDecimal, k as ClickHouseDefault, C as ClickHouseEngines, e as ClickHouseFixedStringSize, f as ClickHouseFloat, g as ClickHouseInt, h as ClickHouseJson, m as ClickHouseMaterialized, j as ClickHouseNamedTuple, b as ClickHousePrecision, l as ClickHouseTTL, D as DateTime, p as DateTime64, r as DateTime64String, q as DateTimeString, A as Decimal, F as FixedString, s as Float32, t as Float64, G as IdentifierBrandedString, B as Insertable, u as Int16, v as Int32, w as Int64, I as Int8, L as LifeCycle, i as LowCardinality, N as NonIdentifierBrandedString, a as OlapConfig, O as OlapTable, R as RawValue, S as S3QueueTableSettings, M as Sql, J as SqlTemplateTag, x as UInt16, y as UInt32, z as UInt64, U as UInt8, H as Value, V as View, W as WithDefault, Y as createClickhouseParameter, X as getValueFromParameter, Z as mapToClickHouseType, E as quoteIdentifier, K as sql, Q as toQuery, T as toQueryPreview, P as toStaticQuery } from './view-CNYx8kUh';
2
3
  import 'typia';
3
- import 'typia/lib/tags';
4
- import 'node:stream';
5
- import '@clickhouse/client';
6
4
  import 'jose';
7
5
  import 'http';
6
+ import '@clickhouse/client';
7
+ import 'typia/lib/tags';
8
+ import 'node:stream';
8
9
 
9
10
  type Key<T extends string | number | Date> = T;
10
11
  type JWT<T extends object> = T;
@@ -101,6 +101,19 @@ Update your tsconfig.json plugins section:
101
101
  Also remove "isolatedModules": true if present (incompatible with type-dependent transformations).`
102
102
  );
103
103
  }
104
+ if (_extrasOrConfig && _extrasOrConfig.ts) {
105
+ var _hostTs = { default: _extrasOrConfig.ts, __esModule: true };
106
+ Object.keys(_extrasOrConfig.ts).forEach(function(k) {
107
+ _hostTs[k] = _extrasOrConfig.ts[k];
108
+ });
109
+ import_typescript = _hostTs;
110
+ import_typescript2 = _hostTs;
111
+ import_typescript3 = _hostTs;
112
+ import_typescript4 = _hostTs;
113
+ import_typescript5 = _hostTs;
114
+ import_typescript6 = _hostTs;
115
+ import_typescript7 = _hostTs;
116
+ }
104
117
  const transformFunction = transform2(program.getTypeChecker(), program);
105
118
  return (context) => {
106
119
  return (sourceFile) => {
@@ -426,6 +439,18 @@ var handleMaterialized = (t, checker) => {
426
439
  }
427
440
  return materializedType.value;
428
441
  };
442
+ var handleAlias = (t, checker) => {
443
+ const aliasType = getTaggedType(t, checker, "_clickhouse_alias");
444
+ if (aliasType === null) {
445
+ return null;
446
+ }
447
+ if (!aliasType.isStringLiteral()) {
448
+ throw new UnsupportedFeature(
449
+ 'ClickHouseAlias must use a string literal, e.g. ClickHouseAlias<"toDate(timestamp)">'
450
+ );
451
+ }
452
+ return aliasType.value;
453
+ };
429
454
  var handleTtl = (t, checker) => {
430
455
  const ttlType = getTaggedType(t, checker, "_clickhouse_ttl");
431
456
  if (ttlType === null) {
@@ -918,9 +943,18 @@ var toColumns = (t, checker, options) => {
918
943
  );
919
944
  const defaultValue = defaultExpression ?? handleDefault(type, checker);
920
945
  const materializedValue = handleMaterialized(type, checker);
921
- if (defaultValue && materializedValue) {
946
+ const aliasValue = handleAlias(type, checker);
947
+ const setCount = [defaultValue, materializedValue, aliasValue].filter(
948
+ (v) => v != null
949
+ ).length;
950
+ if (setCount > 1) {
922
951
  throw new UnsupportedFeature(
923
- `Column '${prop.name}' cannot have both ClickHouseDefault and ClickHouseMaterialized. Use one or the other.`
952
+ `Column '${prop.name}' can only have one of ClickHouseDefault, ClickHouseMaterialized, or ClickHouseAlias.`
953
+ );
954
+ }
955
+ if (aliasValue != null && isKey) {
956
+ throw new UnsupportedFeature(
957
+ `Column '${prop.name}' cannot be a primary key when using ClickHouseAlias.`
924
958
  );
925
959
  }
926
960
  const docComment = prop.getDocumentationComment(checker);
@@ -933,6 +967,7 @@ var toColumns = (t, checker, options) => {
933
967
  unique: false,
934
968
  default: defaultValue,
935
969
  materialized: materializedValue,
970
+ alias: aliasValue,
936
971
  ttl: handleTtl(type, checker),
937
972
  codec: handleCodec(type, checker),
938
973
  annotations,
@@ -1013,6 +1048,50 @@ var generateAssertFunction = (ctx, type, typeName) => {
1013
1048
  config: { equals: false, guard: false }
1014
1049
  });
1015
1050
  };
1051
+ var getPropertyName = (prop) => prop.key.constants?.[0]?.values?.[0]?.value;
1052
+ var patchMetadataForInsert = (metadata, computedColumns, defaultColumns) => {
1053
+ for (const obj of metadata.objects) {
1054
+ const keep = [];
1055
+ for (const prop of obj.type.properties) {
1056
+ const name = getPropertyName(prop);
1057
+ if (name !== void 0 && computedColumns.has(name)) continue;
1058
+ if (name !== void 0 && defaultColumns.has(name)) {
1059
+ prop.value.optional = true;
1060
+ prop.value.required = false;
1061
+ }
1062
+ keep.push(prop);
1063
+ }
1064
+ obj.type.properties.length = 0;
1065
+ obj.type.properties.push(...keep);
1066
+ }
1067
+ };
1068
+ var withInsertableMetadata = (columns, fn) => {
1069
+ const original = import_MetadataFactory.MetadataFactory.analyze;
1070
+ import_MetadataFactory.MetadataFactory.analyze = (props) => {
1071
+ const result = original(props);
1072
+ if (result.success) {
1073
+ patchMetadataForInsert(result.data, columns.computed, columns.defaults);
1074
+ }
1075
+ return result;
1076
+ };
1077
+ try {
1078
+ return fn();
1079
+ } finally {
1080
+ import_MetadataFactory.MetadataFactory.analyze = original;
1081
+ }
1082
+ };
1083
+ var generateInsertValidateFunction = (ctx, type, columns, typeName) => withInsertableMetadata(
1084
+ columns,
1085
+ () => generateValidateFunction(ctx, type, typeName)
1086
+ );
1087
+ var generateInsertIsFunction = (ctx, type, columns, typeName) => withInsertableMetadata(
1088
+ columns,
1089
+ () => generateIsFunction(ctx, type, typeName)
1090
+ );
1091
+ var generateInsertAssertFunction = (ctx, type, columns, typeName) => withInsertableMetadata(
1092
+ columns,
1093
+ () => generateAssertFunction(ctx, type, typeName)
1094
+ );
1016
1095
  var generateHttpAssertQueryFunction = (ctx, type, typeName) => {
1017
1096
  const typiaCtx = toTypiaContext(ctx);
1018
1097
  return import_HttpAssertQueryProgrammer.HttpAssertQueryProgrammer.write({
@@ -1214,18 +1293,16 @@ var transformNewMooseResource = (node, checker, ctx) => {
1214
1293
  }
1215
1294
  const typiaCtx = ctx.typiaContext;
1216
1295
  let internalArguments;
1296
+ let columns;
1217
1297
  if (typeName === "DeadLetterQueue") {
1218
1298
  internalArguments = [generateAssertFunction(typiaCtx, typeAtLocation)];
1219
1299
  } else {
1300
+ columns = toColumns(typeAtLocation, checker, {
1301
+ allowIndexSignatures
1302
+ });
1220
1303
  internalArguments = [
1221
1304
  generateJsonSchemas(typiaCtx, typeAtLocation),
1222
- parseAsAny(
1223
- JSON.stringify(
1224
- toColumns(typeAtLocation, checker, {
1225
- allowIndexSignatures
1226
- })
1227
- )
1228
- )
1305
+ parseAsAny(JSON.stringify(columns))
1229
1306
  ];
1230
1307
  }
1231
1308
  const resourceName = checker.getSymbolAtLocation(node.expression).name;
@@ -1257,6 +1334,48 @@ var transformNewMooseResource = (node, checker, ctx) => {
1257
1334
  true
1258
1335
  );
1259
1336
  updatedArgs = [...updatedArgs, validatorsObject];
1337
+ if (resourceName === "OlapTable" && columns) {
1338
+ const insertColumnSets = {
1339
+ computed: new Set(
1340
+ columns.filter((c) => c.alias != null || c.materialized != null).map((c) => c.name)
1341
+ ),
1342
+ defaults: new Set(
1343
+ columns.filter((c) => c.default != null).map((c) => c.name)
1344
+ )
1345
+ };
1346
+ const insertValidatorsObject = import_typescript5.factory.createObjectLiteralExpression(
1347
+ [
1348
+ import_typescript5.factory.createPropertyAssignment(
1349
+ import_typescript5.factory.createIdentifier("validate"),
1350
+ wrapValidateFunction(
1351
+ generateInsertValidateFunction(
1352
+ typiaCtx,
1353
+ typeAtLocation,
1354
+ insertColumnSets
1355
+ )
1356
+ )
1357
+ ),
1358
+ import_typescript5.factory.createPropertyAssignment(
1359
+ import_typescript5.factory.createIdentifier("assert"),
1360
+ generateInsertAssertFunction(
1361
+ typiaCtx,
1362
+ typeAtLocation,
1363
+ insertColumnSets
1364
+ )
1365
+ ),
1366
+ import_typescript5.factory.createPropertyAssignment(
1367
+ import_typescript5.factory.createIdentifier("is"),
1368
+ generateInsertIsFunction(
1369
+ typiaCtx,
1370
+ typeAtLocation,
1371
+ insertColumnSets
1372
+ )
1373
+ )
1374
+ ],
1375
+ true
1376
+ );
1377
+ updatedArgs = [...updatedArgs, insertValidatorsObject];
1378
+ }
1260
1379
  if (resourceName === "IngestPipeline") {
1261
1380
  updatedArgs = [
1262
1381
  ...updatedArgs,