@statezero/core 0.1.66 → 0.1.67

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.
@@ -23,7 +23,7 @@ export class LiveMetric {
23
23
  */
24
24
  refreshFromDb() {
25
25
  const store = metricRegistry.getStore(this.metricType, this.queryset, this.field);
26
- return store.sync();
26
+ return store.sync(true);
27
27
  }
28
28
  /**
29
29
  * Getter that always returns the current value from the store
@@ -95,7 +95,7 @@ export class LiveQueryset {
95
95
  */
96
96
  refreshFromDb() {
97
97
  const store = querysetStoreRegistry.getStore(__classPrivateFieldGet(this, _LiveQueryset_queryset, "f"));
98
- return store.sync();
98
+ return store.sync(true);
99
99
  }
100
100
  /**
101
101
  * Get the current items from the store
@@ -7,7 +7,6 @@ export class QuerysetStore {
7
7
  groundTruthPks: never[];
8
8
  isSyncing: boolean;
9
9
  lastSync: number | null;
10
- needsSync: boolean;
11
10
  isTemp: any;
12
11
  pruneThreshold: any;
13
12
  getRootStore: any;
@@ -46,6 +45,6 @@ export class QuerysetStore {
46
45
  renderFromRoot(optimistic: boolean | undefined, rootStore: any): any[];
47
46
  renderFromData(optimistic?: boolean): any[];
48
47
  applyOperation(operation: any, currentPks: any): any;
49
- sync(): Promise<void>;
48
+ sync(forceFromDb?: boolean): Promise<void>;
50
49
  }
51
50
  import { Cache } from '../cache/cache.js';
@@ -15,7 +15,6 @@ export class QuerysetStore {
15
15
  this.queryset = queryset;
16
16
  this.isSyncing = false;
17
17
  this.lastSync = null;
18
- this.needsSync = false;
19
18
  this.isTemp = options.isTemp || false;
20
19
  this.pruneThreshold = options.pruneThreshold || 10;
21
20
  this.getRootStore = options.getRootStore || null;
@@ -124,6 +123,7 @@ export class QuerysetStore {
124
123
  }
125
124
  async setGroundTruth(groundTruthPks) {
126
125
  this.groundTruthPks = Array.isArray(groundTruthPks) ? groundTruthPks : [];
126
+ this.lastSync = Date.now();
127
127
  this._emitRenderEvent();
128
128
  }
129
129
  async setOperations(operations) {
@@ -202,7 +202,7 @@ export class QuerysetStore {
202
202
  typeof this.getRootStore === "function" &&
203
203
  !this.isTemp) {
204
204
  const { isRoot, rootStore } = this.getRootStore(this.queryset);
205
- if (!isRoot && rootStore) {
205
+ if (!isRoot && rootStore && (rootStore.lastSync || 0) >= (this.lastSync || 0)) {
206
206
  pks = this.renderFromRoot(optimistic, rootStore);
207
207
  }
208
208
  }
@@ -263,22 +263,21 @@ export class QuerysetStore {
263
263
  }
264
264
  return currentPks;
265
265
  }
266
- async sync() {
266
+ async sync(forceFromDb = false) {
267
267
  const id = this.modelClass.modelName;
268
268
  if (this.isSyncing) {
269
269
  console.warn(`[QuerysetStore ${id}] Already syncing, request ignored.`);
270
270
  return;
271
271
  }
272
272
  // Check if we're delegating to a root store
273
- if (this.getRootStore &&
273
+ if (!forceFromDb &&
274
+ this.getRootStore &&
274
275
  typeof this.getRootStore === "function" &&
275
276
  !this.isTemp) {
276
277
  const { isRoot, rootStore } = this.getRootStore(this.queryset);
277
278
  if (!isRoot && rootStore) {
278
279
  // We're delegating to a root store - don't sync, just mark as needing sync
279
- console.log(`[${id}] Delegating to root store, marking sync needed.`);
280
- this.needsSync = true;
281
- this.lastSync = null; // Clear last sync since we're not actually syncing
280
+ console.log(`[${id}] Delegating to root store.`);
282
281
  this.setOperations(this.getInflightOperations());
283
282
  return;
284
283
  }
@@ -301,12 +300,10 @@ export class QuerysetStore {
301
300
  this.setGroundTruth(data);
302
301
  this.setOperations(this.getInflightOperations());
303
302
  this.lastSync = Date.now();
304
- this.needsSync = false;
305
303
  console.log(`[${id}] Sync completed.`);
306
304
  }
307
305
  catch (e) {
308
306
  console.error(`[${id}] Failed to sync ground truth:`, e);
309
- this.needsSync = true; // Mark as needing sync on error
310
307
  }
311
308
  finally {
312
309
  this.isSyncing = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statezero/core",
3
- "version": "0.1.66",
3
+ "version": "0.1.67",
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",
package/readme.md CHANGED
@@ -205,18 +205,6 @@ npx @statezero/core sync
205
205
 
206
206
  **🆚 Traditional REST APIs:** Write 90% less boilerplate. Focus on features, not data plumbing.
207
207
 
208
- ## Pricing
209
-
210
- StateZero uses a no-rugpull license model:
211
-
212
- - **$0/month** for companies with revenue up to $3M
213
- - **$75/month** for companies with revenue up to $7.5M
214
- - **$200/month** for companies with revenue up to $20M
215
- - **$500/month** for companies with revenue up to $100M
216
- - **$1,000/month** for companies with revenue above $100M
217
-
218
- Lock in your rate forever by signing up early. We can't change your fee or cancel your license.
219
-
220
208
  ## Get Started
221
209
 
222
210
  Run `pip install statezero` and `npm install @statezero/core` to begin.