@nestledjs/data-browser 1.0.2 → 1.0.3

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.
@@ -32,5 +32,6 @@ export declare function buildFormFields(sdk: any, model: DatabaseModel, operatio
32
32
  /**
33
33
  * Clean form input data for GraphQL mutations
34
34
  * Removes Apollo metadata and system fields
35
+ * Handles Prisma array field update syntax
35
36
  */
36
37
  export declare function cleanFormInput(input: Record<string, unknown>, model?: DatabaseModel): Record<string, unknown>;
@@ -436,11 +436,14 @@ function processNestedObject(value, model) {
436
436
  return Object.keys(cleanedNested).length > 0 ? cleanedNested : null;
437
437
  }
438
438
  function cleanFormInput(input, model) {
439
- var _a, _b, _c;
439
+ var _a, _b, _c, _d, _e;
440
440
  const cleaned = {};
441
441
  const booleanFields = new Set(
442
442
  ((_b = (_a = model == null ? void 0 : model.fields) == null ? void 0 : _a.filter((field) => field.type.toLowerCase() === "boolean")) == null ? void 0 : _b.map((field) => field.name)) || []
443
443
  );
444
+ const arrayFields = new Map(
445
+ ((_d = (_c = model == null ? void 0 : model.fields) == null ? void 0 : _c.filter((field) => field.isList && !field.relationName)) == null ? void 0 : _d.map((field) => [field.name, { isRequired: !field.isOptional }])) || []
446
+ );
444
447
  for (const [key, value] of Object.entries(input)) {
445
448
  if (booleanFields.has(key) && value === void 0) {
446
449
  cleaned[key] = false;
@@ -449,8 +452,23 @@ function cleanFormInput(input, model) {
449
452
  if (shouldSkipValue(key, value)) {
450
453
  continue;
451
454
  }
455
+ const arrayFieldInfo = arrayFields.get(key);
456
+ if (arrayFieldInfo) {
457
+ if (value === null || value === "") {
458
+ cleaned[key] = arrayFieldInfo.isRequired ? { set: [] } : null;
459
+ continue;
460
+ }
461
+ let arrayValue;
462
+ if (Array.isArray(value)) {
463
+ arrayValue = value;
464
+ } else {
465
+ arrayValue = [value];
466
+ }
467
+ cleaned[key] = { set: arrayValue };
468
+ continue;
469
+ }
452
470
  if (typeof value === "string") {
453
- const field = (_c = model == null ? void 0 : model.fields) == null ? void 0 : _c.find((f) => f.name === key);
471
+ const field = (_e = model == null ? void 0 : model.fields) == null ? void 0 : _e.find((f) => f.name === key);
454
472
  const convertedValue = convertStringValue(value, field);
455
473
  cleaned[key] = convertedValue;
456
474
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestledjs/data-browser",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Universal admin data browser for Nestled framework projects with full CRUD operations",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -38,7 +38,7 @@
38
38
  "@apollo/client": "^4.0.0",
39
39
  "@heroicons/react": "^2.0.0",
40
40
  "@nestledjs/forms": "^0.5.0",
41
- "@nestledjs/shared-components": "^1.0.2",
41
+ "@nestledjs/shared-components": "^1.0.3",
42
42
  "react": "^19.0.0",
43
43
  "react-router": "^7.0.0"
44
44
  },