@statezero/core 0.1.9 → 0.1.10

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,3 +1,7 @@
1
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
2
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
3
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
4
+ };
1
5
  import { Manager } from "./manager.js";
2
6
  import { ValidationError } from "./errors.js";
3
7
  import { modelStoreRegistry } from "../../syncEngine/registries/modelStoreRegistry.js";
@@ -5,6 +9,7 @@ import { isNil } from "lodash-es";
5
9
  import { QueryExecutor } from "./queryExecutor";
6
10
  import { wrapReactiveModel } from "../../reactiveAdaptor.js";
7
11
  import { DateParsingHelpers } from "./dates.js";
12
+ import { FileObject } from './files.js';
8
13
  /**
9
14
  * A constructor for a Model.
10
15
  *
@@ -70,6 +75,7 @@ export class Model {
70
75
  * @returns {any} The field value
71
76
  */
72
77
  getField(field) {
78
+ var _a;
73
79
  // Access the reactive __version property to establish dependency for vue integration
74
80
  const trackVersion = this.__version;
75
81
  const ModelClass = this.constructor;
@@ -83,15 +89,24 @@ export class Model {
83
89
  if (storedValue)
84
90
  value = storedValue[field]; // if stops null -> undefined
85
91
  }
86
- // File fields need special handling - wrap as FileObject
87
- if (ModelClass.fileFields && ModelClass.fileFields.has(field) && value) {
92
+ // File/Image fields need special handling - wrap as FileObject
93
+ const fileFormats = ["file-path", "image-path"];
94
+ if (ModelClass.schema &&
95
+ fileFormats.includes(ModelClass.schema.properties[field]?.format) &&
96
+ value) {
88
97
  // Check if it's already a FileObject
89
98
  if (value instanceof FileObject) {
90
99
  return value;
91
100
  }
92
101
  // If it's stored file data from API, wrap it as FileObject
93
102
  if (typeof value === "object" && value.file_path) {
94
- return new FileObject(value);
103
+ // Create anonymous subclass with correct configKey
104
+ const BackendFileObject = (_a = class extends FileObject {
105
+ },
106
+ __setFunctionName(_a, "BackendFileObject"),
107
+ _a.configKey = ModelClass.configKey,
108
+ _a);
109
+ return new BackendFileObject(value);
95
110
  }
96
111
  }
97
112
  // relationship fields need special handling
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statezero/core",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
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",