@statezero/core 0.2.25 → 0.2.27

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.
@@ -112,12 +112,18 @@ function processFieldPath(fieldPath, value, ModelClass, options = {}) {
112
112
  }
113
113
  // Recursively process the remaining path with the related model
114
114
  const innerResult = processFieldPath(fullRemainingPath, value, relatedModel, options);
115
+ // Build the full field path including any FK traversal before this M2M field
116
+ // e.g., for owner__roles__name, processedPath=['owner'], part='roles'
117
+ // so fullFieldPath becomes 'owner.roles'
118
+ const fullFieldPath = processedPath.length > 0
119
+ ? processedPath.join('.') + '.' + part
120
+ : part;
115
121
  // Build the required path for data picking (full dot-notation path)
116
122
  const innerRequiredPath = innerResult.requiredPath || innerResult.field;
117
- const requiredPath = `${part}.${innerRequiredPath}`;
123
+ const requiredPath = `${fullFieldPath}.${innerRequiredPath}`;
118
124
  // Wrap the inner result in $elemMatch for this M2M field
119
125
  return {
120
- field: part,
126
+ field: fullFieldPath,
121
127
  operator: { $elemMatch: { [innerResult.field]: innerResult.operator } },
122
128
  isM2M: true,
123
129
  requiredPath // Full path for data picking
@@ -158,7 +164,18 @@ function processFieldPath(fieldPath, value, ModelClass, options = {}) {
158
164
  if (isLastPart) {
159
165
  break;
160
166
  }
161
- // If it's not the last part but it's a regular field,
167
+ // Check if this is a JSON field - if so, we can traverse into it
168
+ const fieldSchema = currentModel.schema?.properties?.[part];
169
+ if (fieldSchema && fieldSchema.format === 'json') {
170
+ // This is a JSON field - add remaining parts as nested key access
171
+ // e.g., json_field__nested__active becomes json_field.nested.active
172
+ const remainingParts = fieldParts.slice(i + 1);
173
+ processedPath.push(...remainingParts);
174
+ // The final field name for schema lookup is still the JSON field itself
175
+ // (remaining parts are just keys within the JSON)
176
+ break;
177
+ }
178
+ // If it's not the last part and not a JSON field,
162
179
  // we can't continue traversal
163
180
  throw new Error(`Field '${part}' in '${fieldPath}' is not a relationship field and cannot be traversed.`);
164
181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statezero/core",
3
- "version": "0.2.25",
3
+ "version": "0.2.27",
4
4
  "type": "module",
5
5
  "module": "ESNext",
6
6
  "description": "The type-safe frontend client for StateZero - connect directly to your backend models with zero boilerplate",