@statezero/core 0.2.15 → 0.2.17
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.
- package/LICENSE +116 -116
- package/dist/adaptors/vue/composables.js +4 -4
- package/dist/cli/commands/syncActions.js +193 -187
- package/dist/cli/commands/syncModels.js +391 -391
- package/dist/core/eventReceivers.d.ts +1 -2
- package/dist/core/eventReceivers.js +16 -16
- package/dist/flavours/django/f.js +1 -1
- package/dist/flavours/django/model.js +1 -1
- package/dist/flavours/django/operationFactory.d.ts +1 -1
- package/dist/flavours/django/operationFactory.js +1 -1
- package/dist/flavours/django/serializers.d.ts +9 -0
- package/dist/flavours/django/serializers.js +31 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- package/dist/syncEngine/metrics/metricOptCalcs.js +1 -1
- package/dist/syncEngine/registries/metricRegistry.d.ts +1 -1
- package/dist/syncEngine/registries/metricRegistry.js +3 -3
- package/dist/syncEngine/stores/metricStore.d.ts +1 -1
- package/dist/syncEngine/stores/metricStore.js +1 -1
- package/dist/syncEngine/stores/operation.d.ts +1 -1
- package/dist/syncEngine/stores/operation.js +1 -1
- package/dist/syncEngine/stores/reactivity.d.ts +3 -3
- package/dist/syncEngine/stores/utils.js +1 -1
- package/dist/syncEngine/sync.d.ts +2 -1
- package/dist/syncEngine/sync.js +10 -9
- package/package.json +126 -126
- package/readme.md +210 -210
- package/dist/actions/backend1/django_app/calculate-hash.d.ts +0 -57
- package/dist/actions/backend1/django_app/calculate-hash.js +0 -77
- package/dist/actions/backend1/django_app/get-current-username.d.ts +0 -29
- package/dist/actions/backend1/django_app/get-current-username.js +0 -62
- package/dist/actions/backend1/django_app/get-server-status.d.ts +0 -38
- package/dist/actions/backend1/django_app/get-server-status.js +0 -65
- package/dist/actions/backend1/django_app/get-user-info.d.ts +0 -44
- package/dist/actions/backend1/django_app/get-user-info.js +0 -67
- package/dist/actions/backend1/django_app/index.d.ts +0 -6
- package/dist/actions/backend1/django_app/index.js +0 -6
- package/dist/actions/backend1/django_app/process-data.d.ts +0 -51
- package/dist/actions/backend1/django_app/process-data.js +0 -75
- package/dist/actions/backend1/django_app/send-notification.d.ts +0 -55
- package/dist/actions/backend1/django_app/send-notification.js +0 -78
- package/dist/actions/backend1/index.d.ts +0 -1
- package/dist/actions/backend1/index.js +0 -1
- package/dist/actions/default/django_app/calculate-hash.d.ts +0 -57
- package/dist/actions/default/django_app/calculate-hash.js +0 -77
- package/dist/actions/default/django_app/get-current-username.d.ts +0 -29
- package/dist/actions/default/django_app/get-current-username.js +0 -62
- package/dist/actions/default/django_app/get-server-status.d.ts +0 -38
- package/dist/actions/default/django_app/get-server-status.js +0 -65
- package/dist/actions/default/django_app/get-user-info.d.ts +0 -44
- package/dist/actions/default/django_app/get-user-info.js +0 -67
- package/dist/actions/default/django_app/index.d.ts +0 -6
- package/dist/actions/default/django_app/index.js +0 -6
- package/dist/actions/default/django_app/process-data.d.ts +0 -51
- package/dist/actions/default/django_app/process-data.js +0 -75
- package/dist/actions/default/django_app/send-notification.d.ts +0 -55
- package/dist/actions/default/django_app/send-notification.js +0 -78
- package/dist/actions/default/index.d.ts +0 -1
- package/dist/actions/default/index.js +0 -1
- package/dist/actions/index.d.ts +0 -1
- package/dist/actions/index.js +0 -5
- package/dist/models/backend1/django_app/comprehensivemodel.d.ts +0 -47
- package/dist/models/backend1/django_app/comprehensivemodel.js +0 -71
- package/dist/models/backend1/django_app/custompkmodel.d.ts +0 -44
- package/dist/models/backend1/django_app/custompkmodel.js +0 -69
- package/dist/models/backend1/django_app/dailyrate.d.ts +0 -47
- package/dist/models/backend1/django_app/dailyrate.js +0 -71
- package/dist/models/backend1/django_app/deepmodellevel1.d.ts +0 -47
- package/dist/models/backend1/django_app/deepmodellevel1.js +0 -72
- package/dist/models/backend1/django_app/deepmodellevel2.d.ts +0 -47
- package/dist/models/backend1/django_app/deepmodellevel2.js +0 -71
- package/dist/models/backend1/django_app/deepmodellevel3.d.ts +0 -44
- package/dist/models/backend1/django_app/deepmodellevel3.js +0 -69
- package/dist/models/backend1/django_app/dummymodel.d.ts +0 -47
- package/dist/models/backend1/django_app/dummymodel.js +0 -71
- package/dist/models/backend1/django_app/dummyrelatedmodel.d.ts +0 -44
- package/dist/models/backend1/django_app/dummyrelatedmodel.js +0 -69
- package/dist/models/backend1/django_app/filetest.d.ts +0 -44
- package/dist/models/backend1/django_app/filetest.js +0 -69
- package/dist/models/backend1/django_app/index.d.ts +0 -16
- package/dist/models/backend1/django_app/index.js +0 -16
- package/dist/models/backend1/django_app/modelwithcustompkrelation.d.ts +0 -47
- package/dist/models/backend1/django_app/modelwithcustompkrelation.js +0 -71
- package/dist/models/backend1/django_app/namefiltercustompkmodel.d.ts +0 -44
- package/dist/models/backend1/django_app/namefiltercustompkmodel.js +0 -69
- package/dist/models/backend1/django_app/order.d.ts +0 -47
- package/dist/models/backend1/django_app/order.js +0 -71
- package/dist/models/backend1/django_app/orderitem.d.ts +0 -47
- package/dist/models/backend1/django_app/orderitem.js +0 -72
- package/dist/models/backend1/django_app/product.d.ts +0 -47
- package/dist/models/backend1/django_app/product.js +0 -71
- package/dist/models/backend1/django_app/productcategory.d.ts +0 -44
- package/dist/models/backend1/django_app/productcategory.js +0 -69
- package/dist/models/backend1/django_app/rateplan.d.ts +0 -44
- package/dist/models/backend1/django_app/rateplan.js +0 -69
- package/dist/models/backend1/fileobject.d.ts +0 -4
- package/dist/models/backend1/fileobject.js +0 -9
- package/dist/models/backend1/index.d.ts +0 -2
- package/dist/models/backend1/index.js +0 -2
- package/dist/models/default/django_app/comprehensivemodel.d.ts +0 -47
- package/dist/models/default/django_app/comprehensivemodel.js +0 -71
- package/dist/models/default/django_app/custompkmodel.d.ts +0 -44
- package/dist/models/default/django_app/custompkmodel.js +0 -69
- package/dist/models/default/django_app/dailyrate.d.ts +0 -47
- package/dist/models/default/django_app/dailyrate.js +0 -71
- package/dist/models/default/django_app/deepmodellevel1.d.ts +0 -47
- package/dist/models/default/django_app/deepmodellevel1.js +0 -72
- package/dist/models/default/django_app/deepmodellevel2.d.ts +0 -47
- package/dist/models/default/django_app/deepmodellevel2.js +0 -71
- package/dist/models/default/django_app/deepmodellevel3.d.ts +0 -44
- package/dist/models/default/django_app/deepmodellevel3.js +0 -69
- package/dist/models/default/django_app/dummymodel.d.ts +0 -47
- package/dist/models/default/django_app/dummymodel.js +0 -71
- package/dist/models/default/django_app/dummyrelatedmodel.d.ts +0 -44
- package/dist/models/default/django_app/dummyrelatedmodel.js +0 -69
- package/dist/models/default/django_app/filetest.d.ts +0 -44
- package/dist/models/default/django_app/filetest.js +0 -69
- package/dist/models/default/django_app/index.d.ts +0 -16
- package/dist/models/default/django_app/index.js +0 -16
- package/dist/models/default/django_app/modelwithcustompkrelation.d.ts +0 -47
- package/dist/models/default/django_app/modelwithcustompkrelation.js +0 -71
- package/dist/models/default/django_app/namefiltercustompkmodel.d.ts +0 -44
- package/dist/models/default/django_app/namefiltercustompkmodel.js +0 -69
- package/dist/models/default/django_app/order.d.ts +0 -47
- package/dist/models/default/django_app/order.js +0 -71
- package/dist/models/default/django_app/orderitem.d.ts +0 -47
- package/dist/models/default/django_app/orderitem.js +0 -72
- package/dist/models/default/django_app/product.d.ts +0 -47
- package/dist/models/default/django_app/product.js +0 -71
- package/dist/models/default/django_app/productcategory.d.ts +0 -44
- package/dist/models/default/django_app/productcategory.js +0 -69
- package/dist/models/default/django_app/rateplan.d.ts +0 -44
- package/dist/models/default/django_app/rateplan.js +0 -69
- package/dist/models/default/fileobject.d.ts +0 -4
- package/dist/models/default/fileobject.js +0 -9
- package/dist/models/default/index.d.ts +0 -2
- package/dist/models/default/index.js +0 -2
- package/dist/models/index.d.ts +0 -1
- package/dist/models/index.js +0 -5
|
@@ -71,7 +71,7 @@ export class PusherEventReceiver {
|
|
|
71
71
|
constructor(options: PusherReceiverOptions, configKey: string);
|
|
72
72
|
configKey: string;
|
|
73
73
|
connectionTimeoutId: NodeJS.Timeout;
|
|
74
|
-
pusherClient:
|
|
74
|
+
pusherClient: any;
|
|
75
75
|
formatChannelName: (arg0: string) => string;
|
|
76
76
|
namespaceResolver: NamespaceResolver;
|
|
77
77
|
channels: Map<any, any>;
|
|
@@ -183,4 +183,3 @@ export type PusherReceiverOptions = {
|
|
|
183
183
|
*/
|
|
184
184
|
namespaceResolver?: NamespaceResolver | undefined;
|
|
185
185
|
};
|
|
186
|
-
import Pusher from "pusher-js";
|
|
@@ -106,22 +106,22 @@ export class PusherEventReceiver {
|
|
|
106
106
|
* @param {string} reason
|
|
107
107
|
*/
|
|
108
108
|
_logConnectionError(reason) {
|
|
109
|
-
console.error(`%c
|
|
110
|
-
████████████████████████████████████████████████████████████████
|
|
111
|
-
█ █
|
|
112
|
-
█ PUSHER CONNECTION FAILED for backend: "${this.configKey}" █
|
|
113
|
-
█ █
|
|
114
|
-
████████████████████████████████████████████████████████████████
|
|
115
|
-
%c
|
|
116
|
-
Reason: ${reason}
|
|
117
|
-
|
|
118
|
-
CRITICAL: Real-time updates from the server will NOT be received.
|
|
119
|
-
This application will not reflect remote changes propagated via Pusher.
|
|
120
|
-
|
|
121
|
-
Common causes:
|
|
122
|
-
1. Incorrect 'appKey' or 'cluster' in the configuration.
|
|
123
|
-
2. The 'authEndpoint' is unreachable or returning an error (check network tab).
|
|
124
|
-
3. Network connectivity issues (firewall, offline).
|
|
109
|
+
console.error(`%c
|
|
110
|
+
████████████████████████████████████████████████████████████████
|
|
111
|
+
█ █
|
|
112
|
+
█ PUSHER CONNECTION FAILED for backend: "${this.configKey}" █
|
|
113
|
+
█ █
|
|
114
|
+
████████████████████████████████████████████████████████████████
|
|
115
|
+
%c
|
|
116
|
+
Reason: ${reason}
|
|
117
|
+
|
|
118
|
+
CRITICAL: Real-time updates from the server will NOT be received.
|
|
119
|
+
This application will not reflect remote changes propagated via Pusher.
|
|
120
|
+
|
|
121
|
+
Common causes:
|
|
122
|
+
1. Incorrect 'appKey' or 'cluster' in the configuration.
|
|
123
|
+
2. The 'authEndpoint' is unreachable or returning an error (check network tab).
|
|
124
|
+
3. Network connectivity issues (firewall, offline).
|
|
125
125
|
4. Using an 'app_id' instead of the 'appKey'.`, "background-color: red; color: white; font-weight: bold; font-size: 16px; padding: 10px;", "color: red; font-size: 12px;");
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
@@ -2,7 +2,7 @@ import { Manager } from "./manager.js";
|
|
|
2
2
|
import { ValidationError } from "./errors.js";
|
|
3
3
|
import { modelStoreRegistry } from "../../syncEngine/registries/modelStoreRegistry.js";
|
|
4
4
|
import { isNil } from "lodash-es";
|
|
5
|
-
import { QueryExecutor } from "./queryExecutor";
|
|
5
|
+
import { QueryExecutor } from "./queryExecutor.js";
|
|
6
6
|
import { wrapReactiveModel } from "../../reactiveAdaptor.js";
|
|
7
7
|
import { DateParsingHelpers } from "./dates.js";
|
|
8
8
|
import { FileObject } from './files.js';
|
|
@@ -70,4 +70,4 @@ export class OperationFactory {
|
|
|
70
70
|
*/
|
|
71
71
|
static createUpdateOrCreateOperation(queryset: QuerySet, lookup?: Object, defaults?: Object, operationId?: string): Operation;
|
|
72
72
|
}
|
|
73
|
-
import { Operation } from '../../syncEngine/stores/operation';
|
|
73
|
+
import { Operation } from '../../syncEngine/stores/operation.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Operation, Type, Status } from '../../syncEngine/stores/operation';
|
|
1
|
+
import { Operation, Type, Status } from '../../syncEngine/stores/operation.js';
|
|
2
2
|
import { v7 as uuid7 } from 'uuid';
|
|
3
3
|
import { createTempPk } from './tempPk.js';
|
|
4
4
|
import { getRequiredFields, pickRequiredFields, processQuery } from '../../filtering/localFiltering.js';
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serializes an action payload based on the action's input schema.
|
|
3
|
+
* Automatically handles model instances (extracts PK), files, dates, etc.
|
|
4
|
+
*
|
|
5
|
+
* @param {Object} payload - The raw payload with potentially model instances
|
|
6
|
+
* @param {Object} inputProperties - The action's input_properties schema
|
|
7
|
+
* @returns {Object} Serialized payload ready for API transmission
|
|
8
|
+
*/
|
|
9
|
+
export function serializeActionPayload(payload: Object, inputProperties: Object): Object;
|
|
1
10
|
export namespace fileFieldSerializer {
|
|
2
11
|
function toInternal(value: any, context?: {}): any;
|
|
3
12
|
function toLive(value: any, context?: {}): any;
|
|
@@ -186,6 +186,37 @@ const serializers = {
|
|
|
186
186
|
"many-to-many": m2mFieldSerializer,
|
|
187
187
|
},
|
|
188
188
|
};
|
|
189
|
+
/**
|
|
190
|
+
* Serializes an action payload based on the action's input schema.
|
|
191
|
+
* Automatically handles model instances (extracts PK), files, dates, etc.
|
|
192
|
+
*
|
|
193
|
+
* @param {Object} payload - The raw payload with potentially model instances
|
|
194
|
+
* @param {Object} inputProperties - The action's input_properties schema
|
|
195
|
+
* @returns {Object} Serialized payload ready for API transmission
|
|
196
|
+
*/
|
|
197
|
+
export function serializeActionPayload(payload, inputProperties) {
|
|
198
|
+
if (!payload || !inputProperties)
|
|
199
|
+
return payload;
|
|
200
|
+
const serializedPayload = {};
|
|
201
|
+
for (const [field, value] of Object.entries(payload)) {
|
|
202
|
+
const fieldSchema = inputProperties[field];
|
|
203
|
+
if (!fieldSchema || value === undefined) {
|
|
204
|
+
serializedPayload[field] = value;
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const { type, format } = fieldSchema;
|
|
208
|
+
// Check if we have a serializer for this type/format combo
|
|
209
|
+
const typeSerializers = serializers[type];
|
|
210
|
+
const serializer = typeSerializers?.[format];
|
|
211
|
+
if (serializer) {
|
|
212
|
+
serializedPayload[field] = serializer.toInternal(value, { field });
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
serializedPayload[field] = value;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return serializedPayload;
|
|
219
|
+
}
|
|
189
220
|
export class ModelSerializer {
|
|
190
221
|
constructor(modelClass) {
|
|
191
222
|
this.modelClass = modelClass;
|
package/dist/index.d.ts
CHANGED
|
@@ -36,4 +36,5 @@ import { cleanupEventHandler } from "./syncEngine/stores/operationEventHandlers.
|
|
|
36
36
|
import { setAdapters } from "./reactiveAdaptor.js";
|
|
37
37
|
import { wrapReactiveModel } from "./reactiveAdaptor.js";
|
|
38
38
|
import { wrapReactiveQuerySet } from "./reactiveAdaptor.js";
|
|
39
|
-
|
|
39
|
+
import { serializeActionPayload } from "./flavours/django/serializers.js";
|
|
40
|
+
export { EventType, PusherEventReceiver, setEventReceiver, getEventReceiver, setNamespaceResolver, setupStateZero, resetStateZero, FileObject, querysetStoreRegistry, modelStoreRegistry, metricRegistry, syncManager, Operation, operationRegistry, Q, StateZeroError, ValidationError, DoesNotExist, PermissionDenied, MultipleObjectsReturned, ASTValidationError, ConfigError, parseStateZeroError, QuerySet, Manager, ResultTuple, Model, setConfig, getConfig, setBackendConfig, initializeEventReceiver, configInstance, getModelClass, initEventHandler, cleanupEventHandler, setAdapters, wrapReactiveModel, wrapReactiveQuerySet, serializeActionPayload };
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { QuerySet } from "./flavours/django/querySet.js";
|
|
|
13
13
|
import { Manager } from "./flavours/django/manager.js";
|
|
14
14
|
import { Model } from "./flavours/django/model.js";
|
|
15
15
|
import { FileObject } from "./flavours/django/files.js";
|
|
16
|
+
import { serializeActionPayload } from "./flavours/django/serializers.js";
|
|
16
17
|
// Configuration
|
|
17
18
|
import { setConfig, getConfig, setBackendConfig, initializeEventReceiver, configInstance, getModelClass, } from "./config.js";
|
|
18
19
|
import { setAdapters, wrapReactiveModel, wrapReactiveQuerySet, } from "./reactiveAdaptor.js";
|
|
@@ -36,4 +37,6 @@ Q, StateZeroError, ValidationError, DoesNotExist, PermissionDenied, MultipleObje
|
|
|
36
37
|
// Configuration
|
|
37
38
|
setConfig, getConfig, setBackendConfig, initializeEventReceiver, configInstance, getModelClass,
|
|
38
39
|
// Reactivity framework integration
|
|
39
|
-
initEventHandler, cleanupEventHandler, setAdapters, wrapReactiveModel, wrapReactiveQuerySet,
|
|
40
|
+
initEventHandler, cleanupEventHandler, setAdapters, wrapReactiveModel, wrapReactiveQuerySet,
|
|
41
|
+
// Action utilities
|
|
42
|
+
serializeActionPayload, };
|
|
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
5
|
};
|
|
6
6
|
var _a, _MetricStrategyFactory_customStrategies, _MetricStrategyFactory_defaultStrategies, _MetricStrategyFactory_generateStrategyKey;
|
|
7
|
-
import { Status, Type } from '../stores/operation';
|
|
7
|
+
import { Status, Type } from '../stores/operation.js';
|
|
8
8
|
import { isNil } from 'lodash-es';
|
|
9
9
|
/**
|
|
10
10
|
* Base class for metric calculation strategies with operations
|
|
@@ -7,7 +7,7 @@ export class LiveMetric {
|
|
|
7
7
|
queryset: any;
|
|
8
8
|
metricType: any;
|
|
9
9
|
field: any;
|
|
10
|
-
get lqs(): import("./querysetStoreRegistry").LiveQueryset;
|
|
10
|
+
get lqs(): import("./querysetStoreRegistry.js").LiveQueryset;
|
|
11
11
|
/**
|
|
12
12
|
* Refresh the metric data from the database
|
|
13
13
|
* Delegates to the underlying store's sync method
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { MetricStore } from '../stores/metricStore';
|
|
1
|
+
import { MetricStore } from '../stores/metricStore.js';
|
|
2
2
|
import { isNil, isEmpty } from 'lodash-es';
|
|
3
|
-
import { querysetStoreRegistry } from './querysetStoreRegistry';
|
|
4
|
-
import { QueryExecutor } from '../../flavours/django/queryExecutor';
|
|
3
|
+
import { querysetStoreRegistry } from './querysetStoreRegistry.js';
|
|
4
|
+
import { QueryExecutor } from '../../flavours/django/queryExecutor.js';
|
|
5
5
|
import { wrapReactiveMetric } from '../../reactiveAdaptor.js';
|
|
6
6
|
import hash from 'object-hash';
|
|
7
7
|
/**
|
|
@@ -11,7 +11,7 @@ export class MetricStore {
|
|
|
11
11
|
fetchFn: any;
|
|
12
12
|
groundTruthValue: any;
|
|
13
13
|
isSyncing: boolean;
|
|
14
|
-
strategy: import("../metrics/metricOptCalcs").MetricCalculationStrategy;
|
|
14
|
+
strategy: import("../metrics/metricOptCalcs.js").MetricCalculationStrategy;
|
|
15
15
|
operations: any[];
|
|
16
16
|
confirmedOps: Set<any>;
|
|
17
17
|
metricCache: Cache;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Cache } from '../cache/cache.js';
|
|
2
|
-
import { MetricStrategyFactory } from "../metrics/metricOptCalcs";
|
|
2
|
+
import { MetricStrategyFactory } from "../metrics/metricOptCalcs.js";
|
|
3
3
|
import hash from 'object-hash';
|
|
4
4
|
import { isNil, isEmpty, isEqual } from 'lodash-es';
|
|
5
5
|
import { metricEventEmitter } from './reactivity.js';
|
|
@@ -13,7 +13,7 @@ var _Operation__instances, _Operation__frozenInstances;
|
|
|
13
13
|
import { MAX, v7 as uuidv7 } from "uuid";
|
|
14
14
|
import { isNil } from 'lodash-es';
|
|
15
15
|
import mitt from 'mitt';
|
|
16
|
-
import { tempPkMap } from "../../flavours/django/tempPk";
|
|
16
|
+
import { tempPkMap } from "../../flavours/django/tempPk.js";
|
|
17
17
|
import { modelStoreRegistry } from "../registries/modelStoreRegistry.js";
|
|
18
18
|
export const operationEvents = mitt();
|
|
19
19
|
export const Status = {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const modelEventEmitter:
|
|
2
|
-
export const querysetEventEmitter:
|
|
3
|
-
export const metricEventEmitter:
|
|
1
|
+
export const modelEventEmitter: any;
|
|
2
|
+
export const querysetEventEmitter: any;
|
|
3
|
+
export const metricEventEmitter: any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNil, isEqual } from 'lodash-es';
|
|
2
|
-
import { filter } from '../../filtering/localFiltering';
|
|
2
|
+
import { filter } from '../../filtering/localFiltering.js';
|
|
3
3
|
/**
|
|
4
4
|
* Guarantees an array of operations, is an array of operations. Handles
|
|
5
5
|
* the basic failure case of a single operation.
|
|
@@ -22,7 +22,8 @@ export class SyncManager {
|
|
|
22
22
|
debounceMs: number;
|
|
23
23
|
maxWaitMs: number;
|
|
24
24
|
batchStartTime: number | null;
|
|
25
|
-
|
|
25
|
+
/** @type {PQueue} */
|
|
26
|
+
syncQueue: PQueue;
|
|
26
27
|
withTimeout(promise: any, ms: any): Promise<any>;
|
|
27
28
|
/**
|
|
28
29
|
* Initialize event handlers for all event receivers
|
package/dist/syncEngine/sync.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { getAllEventReceivers } from "../core/eventReceivers";
|
|
2
|
-
import { operationRegistry } from "./stores/operation";
|
|
3
|
-
import { initializeAllEventReceivers } from "../config";
|
|
4
|
-
import { getEventReceiver } from "../core/eventReceivers";
|
|
5
|
-
import { querysetStoreRegistry, QuerysetStoreRegistry, } from "./registries/querysetStoreRegistry";
|
|
6
|
-
import { modelStoreRegistry, ModelStoreRegistry, } from "./registries/modelStoreRegistry";
|
|
7
|
-
import { metricRegistry, MetricRegistry } from "./registries/metricRegistry";
|
|
8
|
-
import { getModelClass, getConfig } from "../config";
|
|
1
|
+
import { getAllEventReceivers } from "../core/eventReceivers.js";
|
|
2
|
+
import { operationRegistry } from "./stores/operation.js";
|
|
3
|
+
import { initializeAllEventReceivers } from "../config.js";
|
|
4
|
+
import { getEventReceiver } from "../core/eventReceivers.js";
|
|
5
|
+
import { querysetStoreRegistry, QuerysetStoreRegistry, } from "./registries/querysetStoreRegistry.js";
|
|
6
|
+
import { modelStoreRegistry, ModelStoreRegistry, } from "./registries/modelStoreRegistry.js";
|
|
7
|
+
import { metricRegistry, MetricRegistry } from "./registries/metricRegistry.js";
|
|
8
|
+
import { getModelClass, getConfig } from "../config.js";
|
|
9
9
|
import { isNil } from "lodash-es";
|
|
10
|
-
import { QuerysetStore } from "./stores/querysetStore";
|
|
10
|
+
import { QuerysetStore } from "./stores/querysetStore.js";
|
|
11
11
|
import PQueue from "p-queue";
|
|
12
12
|
export class EventPayload {
|
|
13
13
|
constructor(data) {
|
|
@@ -96,6 +96,7 @@ export class SyncManager {
|
|
|
96
96
|
this.maxWaitMs = 2000; // Maximum time to hold events
|
|
97
97
|
this.batchStartTime = null;
|
|
98
98
|
// SyncQueue
|
|
99
|
+
/** @type {PQueue} */
|
|
99
100
|
this.syncQueue = new PQueue({ concurrency: 1 });
|
|
100
101
|
}
|
|
101
102
|
withTimeout(promise, ms) {
|
package/package.json
CHANGED
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@statezero/core",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"module": "ESNext",
|
|
6
|
-
"description": "The type-safe frontend client for StateZero - connect directly to your backend models with zero boilerplate",
|
|
7
|
-
"main": "dist/index.js",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
9
|
-
"bin": {
|
|
10
|
-
"statezero": "dist/cli/index.js"
|
|
11
|
-
},
|
|
12
|
-
"exports": {
|
|
13
|
-
".": {
|
|
14
|
-
"import": "./dist/index.js",
|
|
15
|
-
"require": "./dist/index.js"
|
|
16
|
-
},
|
|
17
|
-
"./cli": {
|
|
18
|
-
"import": "./dist/cli/index.js",
|
|
19
|
-
"require": "./dist/cli/index.js"
|
|
20
|
-
},
|
|
21
|
-
"./react": {
|
|
22
|
-
"import": "./dist/react-entry.js",
|
|
23
|
-
"require": "./dist/react-entry.js"
|
|
24
|
-
},
|
|
25
|
-
"./vue": {
|
|
26
|
-
"import": "./dist/vue-entry.js",
|
|
27
|
-
"require": "./dist/vue-entry.js"
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
"scripts": {
|
|
31
|
-
"test": "vitest run --config=vitest.base.config.ts",
|
|
32
|
-
"test:e2e": "vitest run --config=vitest.sequential.config.ts tests/e2e",
|
|
33
|
-
"generate:test-apps": "ts-node scripts/generate-test-apps.js",
|
|
34
|
-
"test:adaptors": "playwright test tests/adaptors",
|
|
35
|
-
"test:coverage": "vitest run --coverage",
|
|
36
|
-
"build": "tsc",
|
|
37
|
-
"parse-queries": "node scripts/perfect-query-parser.js",
|
|
38
|
-
"sync": "node src/cli/index.js sync",
|
|
39
|
-
"sync:dev": "npx cross-env NODE_ENV=test npm run sync",
|
|
40
|
-
"sync-models": "node src/cli/index.js sync-models",
|
|
41
|
-
"sync-models:dev": "npx cross-env NODE_ENV=test npm run sync-models",
|
|
42
|
-
"sync-actions": "node src/cli/index.js sync-actions",
|
|
43
|
-
"sync-actions:dev": "npx cross-env NODE_ENV=test npm run sync-actions",
|
|
44
|
-
"clean": "npx rimraf dist",
|
|
45
|
-
"prepare": "npm run clean && npm run build",
|
|
46
|
-
"prepublishOnly": "npm run clean && npm run build"
|
|
47
|
-
},
|
|
48
|
-
"keywords": [
|
|
49
|
-
"typescript",
|
|
50
|
-
"orm",
|
|
51
|
-
"backend",
|
|
52
|
-
"frontend",
|
|
53
|
-
"database",
|
|
54
|
-
"sql",
|
|
55
|
-
"django",
|
|
56
|
-
"sqlalchemy",
|
|
57
|
-
"react",
|
|
58
|
-
"vue",
|
|
59
|
-
"svelte"
|
|
60
|
-
],
|
|
61
|
-
"author": "Robert Herring <robert.herring@resipilot.com>",
|
|
62
|
-
"license": "SEE LICENSE IN LICENSE",
|
|
63
|
-
"repository": {
|
|
64
|
-
"type": "git",
|
|
65
|
-
"url": "git+https://github.com/state-zero/statezero-client.git"
|
|
66
|
-
},
|
|
67
|
-
"files": [
|
|
68
|
-
"dist",
|
|
69
|
-
"LICENSE",
|
|
70
|
-
"README.md"
|
|
71
|
-
],
|
|
72
|
-
"homepage": "https://www.statezero.dev",
|
|
73
|
-
"dependencies": {
|
|
74
|
-
"axios": "^1.7.9",
|
|
75
|
-
"cli-progress": "^3.12.0",
|
|
76
|
-
"cosmiconfig": "^9.0.0",
|
|
77
|
-
"cosmiconfig-typescript-loader": "^6.1.0",
|
|
78
|
-
"date-fns": "^4.1.0",
|
|
79
|
-
"dotenv": "^16.4.7",
|
|
80
|
-
"fs-extra": "^11.3.0",
|
|
81
|
-
"graphlib": "^2.1.8",
|
|
82
|
-
"handlebars": "^4.7.8",
|
|
83
|
-
"idb": "^8.0.2",
|
|
84
|
-
"inquirer": "^12.4.2",
|
|
85
|
-
"lodash-es": "^4.17.21",
|
|
86
|
-
"luxon": "^3.6.1",
|
|
87
|
-
"mathjs": "^14.4.0",
|
|
88
|
-
"mitt": "^3.0.1",
|
|
89
|
-
"object-hash": "^3.0.0",
|
|
90
|
-
"openapi-typescript": "^6.7.1",
|
|
91
|
-
"p-queue": "^8.1.0",
|
|
92
|
-
"pusher-js": "^8.4.0",
|
|
93
|
-
"rfdc": "^1.4.1",
|
|
94
|
-
"sift": "^17.1.3",
|
|
95
|
-
"superjson": "^2.2.2",
|
|
96
|
-
"uuid": "^11.1.0",
|
|
97
|
-
"yargs": "^17.7.2",
|
|
98
|
-
"zod": "^3.24.2"
|
|
99
|
-
},
|
|
100
|
-
"devDependencies": {
|
|
101
|
-
"@playwright/test": "^1.50.1",
|
|
102
|
-
"@types/cli-progress": "^3.11.6",
|
|
103
|
-
"@types/lodash-es": "^4.17.12",
|
|
104
|
-
"@types/node": "^22.13.1",
|
|
105
|
-
"@types/react": "^18.3.18",
|
|
106
|
-
"@types/yargs": "^17.0.32",
|
|
107
|
-
"@vitest/coverage-v8": "^3.0.5",
|
|
108
|
-
"fake-indexeddb": "^6.0.0",
|
|
109
|
-
"fast-glob": "^3.3.3",
|
|
110
|
-
"react": "^18.2.0",
|
|
111
|
-
"rimraf": "^5.0.5",
|
|
112
|
-
"ts-node": "^10.9.2",
|
|
113
|
-
"typescript": "^5.7.3",
|
|
114
|
-
"vitest": "^3.0.5",
|
|
115
|
-
"vue": "^3.2.0"
|
|
116
|
-
},
|
|
117
|
-
"publishConfig": {
|
|
118
|
-
"access": "public"
|
|
119
|
-
},
|
|
120
|
-
"bugs": {
|
|
121
|
-
"url": "https://github.com/state-zero/statezero-client/issues"
|
|
122
|
-
},
|
|
123
|
-
"directories": {
|
|
124
|
-
"test": "tests"
|
|
125
|
-
}
|
|
126
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@statezero/core",
|
|
3
|
+
"version": "0.2.17",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"description": "The type-safe frontend client for StateZero - connect directly to your backend models with zero boilerplate",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"bin": {
|
|
10
|
+
"statezero": "dist/cli/index.js"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./cli": {
|
|
18
|
+
"import": "./dist/cli/index.js",
|
|
19
|
+
"require": "./dist/cli/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./react": {
|
|
22
|
+
"import": "./dist/react-entry.js",
|
|
23
|
+
"require": "./dist/react-entry.js"
|
|
24
|
+
},
|
|
25
|
+
"./vue": {
|
|
26
|
+
"import": "./dist/vue-entry.js",
|
|
27
|
+
"require": "./dist/vue-entry.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"test": "vitest run --config=vitest.base.config.ts",
|
|
32
|
+
"test:e2e": "vitest run --config=vitest.sequential.config.ts tests/e2e",
|
|
33
|
+
"generate:test-apps": "ts-node scripts/generate-test-apps.js",
|
|
34
|
+
"test:adaptors": "playwright test tests/adaptors",
|
|
35
|
+
"test:coverage": "vitest run --coverage",
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"parse-queries": "node scripts/perfect-query-parser.js",
|
|
38
|
+
"sync": "node src/cli/index.js sync",
|
|
39
|
+
"sync:dev": "npx cross-env NODE_ENV=test npm run sync",
|
|
40
|
+
"sync-models": "node src/cli/index.js sync-models",
|
|
41
|
+
"sync-models:dev": "npx cross-env NODE_ENV=test npm run sync-models",
|
|
42
|
+
"sync-actions": "node src/cli/index.js sync-actions",
|
|
43
|
+
"sync-actions:dev": "npx cross-env NODE_ENV=test npm run sync-actions",
|
|
44
|
+
"clean": "npx rimraf dist",
|
|
45
|
+
"prepare": "npm run clean && npm run build",
|
|
46
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"typescript",
|
|
50
|
+
"orm",
|
|
51
|
+
"backend",
|
|
52
|
+
"frontend",
|
|
53
|
+
"database",
|
|
54
|
+
"sql",
|
|
55
|
+
"django",
|
|
56
|
+
"sqlalchemy",
|
|
57
|
+
"react",
|
|
58
|
+
"vue",
|
|
59
|
+
"svelte"
|
|
60
|
+
],
|
|
61
|
+
"author": "Robert Herring <robert.herring@resipilot.com>",
|
|
62
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
63
|
+
"repository": {
|
|
64
|
+
"type": "git",
|
|
65
|
+
"url": "git+https://github.com/state-zero/statezero-client.git"
|
|
66
|
+
},
|
|
67
|
+
"files": [
|
|
68
|
+
"dist",
|
|
69
|
+
"LICENSE",
|
|
70
|
+
"README.md"
|
|
71
|
+
],
|
|
72
|
+
"homepage": "https://www.statezero.dev",
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"axios": "^1.7.9",
|
|
75
|
+
"cli-progress": "^3.12.0",
|
|
76
|
+
"cosmiconfig": "^9.0.0",
|
|
77
|
+
"cosmiconfig-typescript-loader": "^6.1.0",
|
|
78
|
+
"date-fns": "^4.1.0",
|
|
79
|
+
"dotenv": "^16.4.7",
|
|
80
|
+
"fs-extra": "^11.3.0",
|
|
81
|
+
"graphlib": "^2.1.8",
|
|
82
|
+
"handlebars": "^4.7.8",
|
|
83
|
+
"idb": "^8.0.2",
|
|
84
|
+
"inquirer": "^12.4.2",
|
|
85
|
+
"lodash-es": "^4.17.21",
|
|
86
|
+
"luxon": "^3.6.1",
|
|
87
|
+
"mathjs": "^14.4.0",
|
|
88
|
+
"mitt": "^3.0.1",
|
|
89
|
+
"object-hash": "^3.0.0",
|
|
90
|
+
"openapi-typescript": "^6.7.1",
|
|
91
|
+
"p-queue": "^8.1.0",
|
|
92
|
+
"pusher-js": "^8.4.0",
|
|
93
|
+
"rfdc": "^1.4.1",
|
|
94
|
+
"sift": "^17.1.3",
|
|
95
|
+
"superjson": "^2.2.2",
|
|
96
|
+
"uuid": "^11.1.0",
|
|
97
|
+
"yargs": "^17.7.2",
|
|
98
|
+
"zod": "^3.24.2"
|
|
99
|
+
},
|
|
100
|
+
"devDependencies": {
|
|
101
|
+
"@playwright/test": "^1.50.1",
|
|
102
|
+
"@types/cli-progress": "^3.11.6",
|
|
103
|
+
"@types/lodash-es": "^4.17.12",
|
|
104
|
+
"@types/node": "^22.13.1",
|
|
105
|
+
"@types/react": "^18.3.18",
|
|
106
|
+
"@types/yargs": "^17.0.32",
|
|
107
|
+
"@vitest/coverage-v8": "^3.0.5",
|
|
108
|
+
"fake-indexeddb": "^6.0.0",
|
|
109
|
+
"fast-glob": "^3.3.3",
|
|
110
|
+
"react": "^18.2.0",
|
|
111
|
+
"rimraf": "^5.0.5",
|
|
112
|
+
"ts-node": "^10.9.2",
|
|
113
|
+
"typescript": "^5.7.3",
|
|
114
|
+
"vitest": "^3.0.5",
|
|
115
|
+
"vue": "^3.2.0"
|
|
116
|
+
},
|
|
117
|
+
"publishConfig": {
|
|
118
|
+
"access": "public"
|
|
119
|
+
},
|
|
120
|
+
"bugs": {
|
|
121
|
+
"url": "https://github.com/state-zero/statezero-client/issues"
|
|
122
|
+
},
|
|
123
|
+
"directories": {
|
|
124
|
+
"test": "tests"
|
|
125
|
+
}
|
|
126
|
+
}
|