@restura/core 0.1.0-alpha.10 → 0.1.0-alpha.11

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/index.mjs CHANGED
@@ -494,7 +494,7 @@ var ApiTree = class _ApiTree {
494
494
  break;
495
495
  }
496
496
  }
497
- return `'${p.name}'${p.required ? "" : "?"}:${requestType}`;
497
+ return `'${p.name}'${p.required ? "" : "?"}:${requestType}${p.isNullable ? " | null" : ""}`;
498
498
  }).join(";\n")}${ObjectUtils.isArrayWithData(route.request) ? ";" : ""}
499
499
  `;
500
500
  modelString += `}`;
@@ -518,18 +518,18 @@ var ApiTree = class _ApiTree {
518
518
  return nested;
519
519
  }
520
520
  getNameAndType(p) {
521
- let responseType = "any", optional = false, array = false;
521
+ let responseType = "any", isNullable = false, array = false;
522
522
  if (p.selector) {
523
- ({ responseType, optional } = this.getTypeFromTable(p.selector, p.name));
523
+ ({ responseType, isNullable } = this.getTypeFromTable(p.selector, p.name));
524
524
  } else if (p.subquery) {
525
525
  responseType = this.getFields(p.subquery.properties);
526
526
  array = true;
527
527
  }
528
- return `${p.name}${optional ? "?" : ""}:${responseType}${array ? "[]" : ""}`;
528
+ return `${p.name}:${responseType}${array ? "[]" : ""}${isNullable ? " | null" : ""}`;
529
529
  }
530
530
  getTypeFromTable(selector, name) {
531
531
  const path4 = selector.split(".");
532
- if (path4.length === 0 || path4.length > 2 || path4[0] === "") return { responseType: "any", optional: false };
532
+ if (path4.length === 0 || path4.length > 2 || path4[0] === "") return { responseType: "any", isNullable: false };
533
533
  let tableName = path4.length == 2 ? path4[0] : name;
534
534
  const columnName = path4.length == 2 ? path4[1] : path4[0];
535
535
  let table = this.database.find((t) => t.name == tableName);
@@ -539,10 +539,10 @@ var ApiTree = class _ApiTree {
539
539
  table = this.database.find((t) => t.name == tableName);
540
540
  }
541
541
  const column = table == null ? void 0 : table.columns.find((c) => c.name == columnName);
542
- if (!table || !column) return { responseType: "any", optional: false };
542
+ if (!table || !column) return { responseType: "any", isNullable: false };
543
543
  return {
544
544
  responseType: SqlUtils.convertDatabaseTypeToTypescript(column.type, column.value),
545
- optional: column.roles.length > 0 || column.isNullable
545
+ isNullable: column.roles.length > 0 || column.isNullable
546
546
  };
547
547
  }
548
548
  };
@@ -748,6 +748,7 @@ var joinDataSchema = z3.object({
748
748
  var requestDataSchema = z3.object({
749
749
  name: z3.string(),
750
750
  required: z3.boolean(),
751
+ isNullable: z3.boolean().optional().default(false),
751
752
  validator: z3.array(validatorDataSchema)
752
753
  }).strict();
753
754
  var responseDataSchema = z3.object({
@@ -1023,6 +1024,7 @@ function validateRequestParams(req, routeData, validationSchema) {
1023
1024
  });
1024
1025
  }
1025
1026
  function validateRequestSingleParam(requestValue, requestParam) {
1027
+ if (requestParam.isNullable && requestValue === null) return;
1026
1028
  requestParam.validator.forEach((validator) => {
1027
1029
  switch (validator.type) {
1028
1030
  case "TYPE_CHECK":