@statezero/core 0.1.84 → 0.1.86

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.
@@ -37,7 +37,6 @@ function relatedQuerysets(queryset) {
37
37
  }
38
38
  /**
39
39
  * Process an operation in the model store
40
- * Only processes if the model store doesn't already have the operation.
41
40
  *
42
41
  * @param {Operation} operation - The operation to process
43
42
  * @param {string} actionType - The action to perform ('add', 'update', 'confirm', 'reject')
@@ -47,10 +46,6 @@ function processModelStore(operation, actionType) {
47
46
  const modelStore = modelStoreRegistry.getStore(ModelClass);
48
47
  if (!modelStore)
49
48
  return;
50
- // Skip if the model store already has this operation
51
- if (modelStore.operationsMap.has(operation.operationId)) {
52
- return;
53
- }
54
49
  switch (actionType) {
55
50
  case 'add':
56
51
  modelStore.addOperation(operation);
@@ -118,12 +113,7 @@ function processQuerysetStores(operation, actionType) {
118
113
  querysetStoreMap = relatedQuerysets(queryset);
119
114
  break;
120
115
  }
121
- // Filter to only stores that DON'T already have this operation
122
- const storesToRoute = Array.from(querysetStoreMap.values()).filter(store => {
123
- return !store.operationsMap.has(operation.operationId);
124
- });
125
- // Route only to stores that don't have the operation yet
126
- storesToRoute.forEach(applyAction);
116
+ Array.from(querysetStoreMap.values()).forEach(applyAction);
127
117
  }
128
118
  /**
129
119
  * Process an operation in the metric stores based on operation type
@@ -16,7 +16,16 @@ export class EventPayload {
16
16
  this.operation_id = data.operation_id;
17
17
  this.pk_field_name = data.pk_field_name;
18
18
  this.configKey = data.configKey;
19
- this.instances = data.instances;
19
+ const pkType = getModelClass(data.model, data.configKey)?.schema
20
+ ?.properties?.[data.pk_field_name]?.type;
21
+ this.instances =
22
+ data.instances?.map((inst) => {
23
+ const pk = inst?.[data.pk_field_name];
24
+ if (pk != null && pkType === "integer" && typeof pk === "string") {
25
+ inst[data.pk_field_name] = parseInt(pk, 10);
26
+ }
27
+ return inst;
28
+ }) || [];
20
29
  this._cachedInstances = null;
21
30
  }
22
31
  get modelClass() {
@@ -46,19 +55,7 @@ export class SyncManager {
46
55
  this.processMetrics(payload);
47
56
  }
48
57
  if (isLocalOperation) {
49
- // Check if any stores for this model class DON'T have the operation yet
50
- const modelStore = modelStoreRegistry.getStore(payload.modelClass);
51
- const querysetStores = querysetStoreRegistry.getAllStoresForModel(payload.modelClass);
52
- // If model store and all queryset stores already have the operation, skip
53
- // Note: getStore() always returns a store (creates if needed)
54
- // and operationsMap is always initialized in constructors
55
- const modelStoreHasIt = modelStore.operationsMap.has(payload.operation_id);
56
- const allQuerysetStoresHaveIt = querysetStores.length === 0 ||
57
- querysetStores.every(store => store.operationsMap.has(payload.operation_id));
58
- if (modelStoreHasIt && allQuerysetStoresHaveIt) {
59
- return; // All stores already have it, no need to process
60
- }
61
- // Otherwise, continue to process for stores that don't have it yet
58
+ return;
62
59
  }
63
60
  // Add to batch for queryset/model processing
64
61
  const key = `${event.model}::${event.configKey}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statezero/core",
3
- "version": "0.1.84",
3
+ "version": "0.1.86",
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",