@ghentcdh/crouton-api 0.0.1-alpha.2 → 0.0.1-alpha.20

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.cjs CHANGED
@@ -2498,7 +2498,7 @@ var import_node_fs2 = require("fs");
2498
2498
  var import_node_module = require("module");
2499
2499
  var import_node_path2 = require("path");
2500
2500
  var import_meta = {};
2501
- var _require = (0, import_node_module.createRequire)(import_meta.url);
2501
+ var _require = (0, import_node_module.createRequire)(import_meta.url ?? __filename);
2502
2502
  var findModule2 = /* @__PURE__ */ __name((dir, name) => {
2503
2503
  for (const ext of [
2504
2504
  ".ts",
@@ -3025,6 +3025,13 @@ var buildView = /* @__PURE__ */ __name((schema, columns, visible, buildUiSchema,
3025
3025
  allowAdditionalProperties(jsonSchema);
3026
3026
  dropNullableFromRequired2(jsonSchema);
3027
3027
  enforceRequiredMinLength(jsonSchema);
3028
+ if (schemaVisible) {
3029
+ const nonEditableIds = new Set(schemaCols.filter((c) => c.createable === false && c.updateable === false).map((c) => c.id));
3030
+ const required = jsonSchema["required"];
3031
+ if (Array.isArray(required) && nonEditableIds.size) {
3032
+ jsonSchema["required"] = required.filter((k) => !nonEditableIds.has(k));
3033
+ }
3034
+ }
3028
3035
  return {
3029
3036
  json_schema: jsonSchema,
3030
3037
  ui_schema: buildUiSchema(visibleCols),
@@ -3169,8 +3176,12 @@ var buildViewsFromColumns = /* @__PURE__ */ __name((columns) => {
3169
3176
  title: c.label ?? c.id
3170
3177
  };
3171
3178
  } else {
3179
+ const opts = c.fieldInput?.options;
3180
+ const isObject = opts?.emitObject === true || c.fieldInput?.type === "autocomplete";
3172
3181
  properties[c.id] = {
3173
- type: c.columnType ?? "string",
3182
+ ...isObject ? {} : {
3183
+ type: c.columnType ?? "string"
3184
+ },
3174
3185
  title: c.label ?? c.id
3175
3186
  };
3176
3187
  }