@statezero/core 0.2.28 → 0.2.30
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/dist/actions/backend1/django_app/calculate-hash.js +1 -1
- package/dist/actions/backend1/django_app/calculate-hash.schema.json +1 -1
- package/dist/actions/backend1/django_app/get-current-username.js +1 -1
- package/dist/actions/backend1/django_app/get-current-username.schema.json +1 -1
- package/dist/actions/backend1/django_app/get-user-info.js +1 -1
- package/dist/actions/backend1/django_app/get-user-info.schema.json +1 -1
- package/dist/actions/backend1/django_app/process-data.js +1 -1
- package/dist/actions/backend1/django_app/process-data.schema.json +1 -1
- package/dist/actions/backend1/django_app/send-notification.js +1 -1
- package/dist/actions/backend1/django_app/send-notification.schema.json +1 -1
- package/dist/actions/default/django_app/calculate-hash.js +1 -1
- package/dist/actions/default/django_app/calculate-hash.schema.json +1 -1
- package/dist/actions/default/django_app/get-current-username.js +1 -1
- package/dist/actions/default/django_app/get-current-username.schema.json +1 -1
- package/dist/actions/default/django_app/get-user-info.js +1 -1
- package/dist/actions/default/django_app/get-user-info.schema.json +1 -1
- package/dist/actions/default/django_app/process-data.js +1 -1
- package/dist/actions/default/django_app/process-data.schema.json +1 -1
- package/dist/actions/default/django_app/send-notification.js +1 -1
- package/dist/actions/default/django_app/send-notification.schema.json +1 -1
- package/dist/flavours/django/makeApiCall.d.ts +14 -1
- package/dist/flavours/django/makeApiCall.js +31 -3
- package/dist/models/backend1/django_app/comprehensivemodel.schema.json +1 -1
- package/dist/models/backend1/django_app/custompkmodel.schema.json +4 -4
- package/dist/models/backend1/django_app/dailyrate.schema.json +8 -8
- package/dist/models/backend1/django_app/dummymodel.schema.json +2 -2
- package/dist/models/backend1/django_app/m2mdepthtestlevel1.schema.json +2 -2
- package/dist/models/backend1/django_app/m2mdepthtestlevel2.schema.json +1 -1
- package/dist/models/backend1/django_app/m2mdepthtestlevel3.schema.json +5 -5
- package/dist/models/backend1/django_app/modelwithrestrictedfields.schema.json +1 -1
- package/dist/models/backend1/django_app/namefiltercustompkmodel.schema.json +4 -4
- package/dist/models/backend1/django_app/order.schema.json +8 -8
- package/dist/models/backend1/django_app/orderitem.schema.json +1 -1
- package/dist/models/backend1/django_app/product.schema.json +9 -9
- package/dist/models/backend1/django_app/productcategory.schema.json +2 -2
- package/dist/models/backend1/django_app/rateplan.schema.json +2 -2
- package/dist/models/backend1/django_app/restrictedfieldrelatedmodel.schema.json +2 -2
- package/dist/models/default/django_app/comprehensivemodel.schema.json +1 -1
- package/dist/models/default/django_app/custompkmodel.schema.json +4 -4
- package/dist/models/default/django_app/dailyrate.schema.json +8 -8
- package/dist/models/default/django_app/dummymodel.schema.json +2 -2
- package/dist/models/default/django_app/m2mdepthtestlevel1.schema.json +2 -2
- package/dist/models/default/django_app/m2mdepthtestlevel2.schema.json +1 -1
- package/dist/models/default/django_app/m2mdepthtestlevel3.schema.json +5 -5
- package/dist/models/default/django_app/modelwithrestrictedfields.schema.json +1 -1
- package/dist/models/default/django_app/namefiltercustompkmodel.schema.json +4 -4
- package/dist/models/default/django_app/order.schema.json +8 -8
- package/dist/models/default/django_app/orderitem.schema.json +1 -1
- package/dist/models/default/django_app/product.schema.json +9 -9
- package/dist/models/default/django_app/productcategory.schema.json +2 -2
- package/dist/models/default/django_app/rateplan.schema.json +2 -2
- package/dist/models/default/django_app/restrictedfieldrelatedmodel.schema.json +2 -2
- package/dist/syncEngine/registries/querysetStoreGraph.d.ts +15 -5
- package/dist/syncEngine/registries/querysetStoreGraph.js +64 -22
- package/dist/syncEngine/registries/querysetStoreRegistry.d.ts +14 -10
- package/dist/syncEngine/registries/querysetStoreRegistry.js +66 -40
- package/dist/syncEngine/stores/operationEventHandlers.js +12 -20
- package/dist/syncEngine/stores/querysetStore.d.ts +9 -11
- package/dist/syncEngine/stores/querysetStore.js +34 -100
- package/dist/syncEngine/sync.d.ts +1 -4
- package/dist/syncEngine/sync.js +27 -21
- package/package.json +1 -1
|
@@ -76,5 +76,5 @@ export default calculateHash;
|
|
|
76
76
|
calculateHash.actionName = 'calculate_hash';
|
|
77
77
|
calculateHash.title = 'Calculate Hash';
|
|
78
78
|
calculateHash.app = 'django_app';
|
|
79
|
-
calculateHash.permissions = ['
|
|
79
|
+
calculateHash.permissions = ['ValidatedIsAuthenticated'];
|
|
80
80
|
calculateHash.configKey = 'backend1';
|
|
@@ -61,5 +61,5 @@ export default getCurrentUsername;
|
|
|
61
61
|
getCurrentUsername.actionName = 'get_current_username';
|
|
62
62
|
getCurrentUsername.title = 'Get Current Username';
|
|
63
63
|
getCurrentUsername.app = 'django_app';
|
|
64
|
-
getCurrentUsername.permissions = ['
|
|
64
|
+
getCurrentUsername.permissions = ['ValidatedIsAuthenticated'];
|
|
65
65
|
getCurrentUsername.configKey = 'backend1';
|
|
@@ -66,5 +66,5 @@ export default getUserInfo;
|
|
|
66
66
|
getUserInfo.actionName = 'get_user_info';
|
|
67
67
|
getUserInfo.title = 'Get User Info';
|
|
68
68
|
getUserInfo.app = 'django_app';
|
|
69
|
-
getUserInfo.permissions = ['
|
|
69
|
+
getUserInfo.permissions = ['ValidatedIsAuthenticated'];
|
|
70
70
|
getUserInfo.configKey = 'backend1';
|
|
@@ -74,5 +74,5 @@ export default processData;
|
|
|
74
74
|
processData.actionName = 'process_data';
|
|
75
75
|
processData.title = 'Process Data';
|
|
76
76
|
processData.app = 'django_app';
|
|
77
|
-
processData.permissions = ['
|
|
77
|
+
processData.permissions = ['ValidatedHasValidApiKey'];
|
|
78
78
|
processData.configKey = 'backend1';
|
|
@@ -77,5 +77,5 @@ export default sendNotification;
|
|
|
77
77
|
sendNotification.actionName = 'send_notification';
|
|
78
78
|
sendNotification.title = 'Send Notification';
|
|
79
79
|
sendNotification.app = 'django_app';
|
|
80
|
-
sendNotification.permissions = ['
|
|
80
|
+
sendNotification.permissions = ['ValidatedCanSendNotifications'];
|
|
81
81
|
sendNotification.configKey = 'backend1';
|
|
@@ -76,5 +76,5 @@ export default calculateHash;
|
|
|
76
76
|
calculateHash.actionName = 'calculate_hash';
|
|
77
77
|
calculateHash.title = 'Calculate Hash';
|
|
78
78
|
calculateHash.app = 'django_app';
|
|
79
|
-
calculateHash.permissions = ['
|
|
79
|
+
calculateHash.permissions = ['ValidatedIsAuthenticated'];
|
|
80
80
|
calculateHash.configKey = 'default';
|
|
@@ -61,5 +61,5 @@ export default getCurrentUsername;
|
|
|
61
61
|
getCurrentUsername.actionName = 'get_current_username';
|
|
62
62
|
getCurrentUsername.title = 'Get Current Username';
|
|
63
63
|
getCurrentUsername.app = 'django_app';
|
|
64
|
-
getCurrentUsername.permissions = ['
|
|
64
|
+
getCurrentUsername.permissions = ['ValidatedIsAuthenticated'];
|
|
65
65
|
getCurrentUsername.configKey = 'default';
|
|
@@ -66,5 +66,5 @@ export default getUserInfo;
|
|
|
66
66
|
getUserInfo.actionName = 'get_user_info';
|
|
67
67
|
getUserInfo.title = 'Get User Info';
|
|
68
68
|
getUserInfo.app = 'django_app';
|
|
69
|
-
getUserInfo.permissions = ['
|
|
69
|
+
getUserInfo.permissions = ['ValidatedIsAuthenticated'];
|
|
70
70
|
getUserInfo.configKey = 'default';
|
|
@@ -74,5 +74,5 @@ export default processData;
|
|
|
74
74
|
processData.actionName = 'process_data';
|
|
75
75
|
processData.title = 'Process Data';
|
|
76
76
|
processData.app = 'django_app';
|
|
77
|
-
processData.permissions = ['
|
|
77
|
+
processData.permissions = ['ValidatedHasValidApiKey'];
|
|
78
78
|
processData.configKey = 'default';
|
|
@@ -77,5 +77,5 @@ export default sendNotification;
|
|
|
77
77
|
sendNotification.actionName = 'send_notification';
|
|
78
78
|
sendNotification.title = 'Send Notification';
|
|
79
79
|
sendNotification.app = 'django_app';
|
|
80
|
-
sendNotification.permissions = ['
|
|
80
|
+
sendNotification.permissions = ['ValidatedCanSendNotifications'];
|
|
81
81
|
sendNotification.configKey = 'default';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a promise with a timeout.
|
|
3
|
+
* @param {Promise} promise - The promise to wrap
|
|
4
|
+
* @param {number} ms - Timeout in milliseconds (default: 30000)
|
|
5
|
+
* @returns {Promise} - Resolves with promise result or rejects on timeout
|
|
6
|
+
*/
|
|
7
|
+
export function withTimeout(promise: Promise<any>, ms?: number): Promise<any>;
|
|
1
8
|
/**
|
|
2
9
|
* Process included entities from a response and register them in the model store.
|
|
3
10
|
* Uses the model registry to find the appropriate model class for each entity type.
|
|
@@ -18,6 +25,12 @@ export function processIncludedEntities(modelStoreRegistry: ModelStoreRegistry,
|
|
|
18
25
|
* @param {string} operationId - A unique id for the operation
|
|
19
26
|
* @param {Function} beforeExit - Optional callback before returning
|
|
20
27
|
* @param {string} canonicalId - Optional canonical_id for cache sharing
|
|
28
|
+
* @param {Object} options - Additional options
|
|
29
|
+
* @param {string} options.namespace - Queue namespace ('default' for app ops, 'sync' for background sync)
|
|
30
|
+
* @param {number} options.timeout - Timeout in ms (default: no timeout)
|
|
21
31
|
* @returns {Promise<Object>} The API response.
|
|
22
32
|
*/
|
|
23
|
-
export function makeApiCall(querySet: QuerySet, operationType: string, args: Object | undefined, operationId: string, beforeExit?: Function, canonicalId?: string
|
|
33
|
+
export function makeApiCall(querySet: QuerySet, operationType: string, args: Object | undefined, operationId: string, beforeExit?: Function, canonicalId?: string, options?: {
|
|
34
|
+
namespace: string;
|
|
35
|
+
timeout: number;
|
|
36
|
+
}): Promise<Object>;
|
|
@@ -5,7 +5,27 @@ import { replaceTempPks } from './tempPk.js';
|
|
|
5
5
|
import { parseStateZeroError, MultipleObjectsReturned, DoesNotExist } from './errors.js';
|
|
6
6
|
import { FileObject } from './files.js';
|
|
7
7
|
import { querysetStoreRegistry } from '../../syncEngine/registries/querysetStoreRegistry.js';
|
|
8
|
-
|
|
8
|
+
// Namespace-based queues: separate queues for different operation types
|
|
9
|
+
// This prevents sync operations from blocking user-initiated app operations
|
|
10
|
+
const queues = new Map();
|
|
11
|
+
function getQueue(namespace = 'default') {
|
|
12
|
+
if (!queues.has(namespace)) {
|
|
13
|
+
queues.set(namespace, new PQueue({ concurrency: 1 }));
|
|
14
|
+
}
|
|
15
|
+
return queues.get(namespace);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Wraps a promise with a timeout.
|
|
19
|
+
* @param {Promise} promise - The promise to wrap
|
|
20
|
+
* @param {number} ms - Timeout in milliseconds (default: 30000)
|
|
21
|
+
* @returns {Promise} - Resolves with promise result or rejects on timeout
|
|
22
|
+
*/
|
|
23
|
+
export function withTimeout(promise, ms = 30000) {
|
|
24
|
+
return Promise.race([
|
|
25
|
+
promise,
|
|
26
|
+
new Promise((_, reject) => setTimeout(() => reject(new Error(`Request timeout after ${ms}ms`)), ms)),
|
|
27
|
+
]);
|
|
28
|
+
}
|
|
9
29
|
/**
|
|
10
30
|
* Process included entities from a response and register them in the model store.
|
|
11
31
|
* Uses the model registry to find the appropriate model class for each entity type.
|
|
@@ -64,9 +84,13 @@ export function processIncludedEntities(modelStoreRegistry, included, ModelClass
|
|
|
64
84
|
* @param {string} operationId - A unique id for the operation
|
|
65
85
|
* @param {Function} beforeExit - Optional callback before returning
|
|
66
86
|
* @param {string} canonicalId - Optional canonical_id for cache sharing
|
|
87
|
+
* @param {Object} options - Additional options
|
|
88
|
+
* @param {string} options.namespace - Queue namespace ('default' for app ops, 'sync' for background sync)
|
|
89
|
+
* @param {number} options.timeout - Timeout in ms (default: no timeout)
|
|
67
90
|
* @returns {Promise<Object>} The API response.
|
|
68
91
|
*/
|
|
69
|
-
export async function makeApiCall(querySet, operationType, args = {}, operationId, beforeExit = null, canonicalId = null) {
|
|
92
|
+
export async function makeApiCall(querySet, operationType, args = {}, operationId, beforeExit = null, canonicalId = null, options = {}) {
|
|
93
|
+
const { namespace = 'default', timeout } = options;
|
|
70
94
|
const ModelClass = querySet.ModelClass;
|
|
71
95
|
const config = configInstance.getConfig();
|
|
72
96
|
const backend = config.backendConfigs[ModelClass.configKey];
|
|
@@ -133,5 +157,9 @@ export async function makeApiCall(querySet, operationType, args = {}, operationI
|
|
|
133
157
|
}
|
|
134
158
|
};
|
|
135
159
|
// Queue write operations, execute read operations immediately
|
|
136
|
-
|
|
160
|
+
// Use namespace-based queues to separate sync ops from app ops
|
|
161
|
+
const queue = getQueue(namespace);
|
|
162
|
+
const queuedCall = isWriteOperation ? queue.add(apiCall) : apiCall();
|
|
163
|
+
// Apply timeout if specified
|
|
164
|
+
return timeout ? withTimeout(queuedCall, timeout) : queuedCall;
|
|
137
165
|
}
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
"plural_title": "Custom Pk Models",
|
|
6
6
|
"primary_key_field": "custom_pk",
|
|
7
7
|
"filterable_fields": [
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"custom_pk",
|
|
9
|
+
"name"
|
|
10
10
|
],
|
|
11
11
|
"searchable_fields": [
|
|
12
12
|
"name"
|
|
13
13
|
],
|
|
14
14
|
"ordering_fields": [
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"custom_pk",
|
|
16
|
+
"name"
|
|
17
17
|
],
|
|
18
18
|
"properties": {
|
|
19
19
|
"custom_pk": {
|
|
@@ -5,21 +5,21 @@
|
|
|
5
5
|
"plural_title": "Daily Rates",
|
|
6
6
|
"primary_key_field": "id",
|
|
7
7
|
"filterable_fields": [
|
|
8
|
-
"
|
|
9
|
-
"date",
|
|
10
|
-
"rate_plan",
|
|
8
|
+
"stop_sell",
|
|
11
9
|
"min_stay_arrival",
|
|
10
|
+
"id",
|
|
12
11
|
"price",
|
|
13
|
-
"max_stay",
|
|
14
12
|
"min_stay_through",
|
|
15
|
-
"
|
|
13
|
+
"rate_plan",
|
|
16
14
|
"closed_to_arrival",
|
|
17
|
-
"
|
|
15
|
+
"max_stay",
|
|
16
|
+
"closed_to_departure",
|
|
17
|
+
"date"
|
|
18
18
|
],
|
|
19
19
|
"searchable_fields": [],
|
|
20
20
|
"ordering_fields": [
|
|
21
|
-
"
|
|
22
|
-
"
|
|
21
|
+
"date",
|
|
22
|
+
"rate_plan"
|
|
23
23
|
],
|
|
24
24
|
"properties": {
|
|
25
25
|
"id": {
|
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
"plural_title": "M2M Depth Test Level3S",
|
|
6
6
|
"primary_key_field": "id",
|
|
7
7
|
"filterable_fields": [
|
|
8
|
-
"name",
|
|
9
8
|
"id",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
9
|
+
"value",
|
|
10
|
+
"name",
|
|
11
|
+
"category"
|
|
12
12
|
],
|
|
13
13
|
"searchable_fields": [
|
|
14
14
|
"name"
|
|
15
15
|
],
|
|
16
16
|
"ordering_fields": [
|
|
17
|
-
"
|
|
18
|
-
"
|
|
17
|
+
"value",
|
|
18
|
+
"name"
|
|
19
19
|
],
|
|
20
20
|
"properties": {
|
|
21
21
|
"id": {
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
"plural_title": "Name Filter Custom Pk Models",
|
|
6
6
|
"primary_key_field": "custom_pk",
|
|
7
7
|
"filterable_fields": [
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"custom_pk",
|
|
9
|
+
"name"
|
|
10
10
|
],
|
|
11
11
|
"searchable_fields": [
|
|
12
12
|
"name"
|
|
13
13
|
],
|
|
14
14
|
"ordering_fields": [
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"custom_pk",
|
|
16
|
+
"name"
|
|
17
17
|
],
|
|
18
18
|
"properties": {
|
|
19
19
|
"custom_pk": {
|
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
"plural_title": "Orders",
|
|
6
6
|
"primary_key_field": "id",
|
|
7
7
|
"filterable_fields": [
|
|
8
|
+
"status",
|
|
9
|
+
"total",
|
|
8
10
|
"id",
|
|
9
|
-
"
|
|
11
|
+
"created_at",
|
|
10
12
|
"customer_name",
|
|
11
|
-
"
|
|
12
|
-
"order_number",
|
|
13
|
+
"customer_email",
|
|
13
14
|
"last_updated",
|
|
14
|
-
"
|
|
15
|
-
"total"
|
|
15
|
+
"order_number"
|
|
16
16
|
],
|
|
17
17
|
"searchable_fields": [
|
|
18
|
-
"
|
|
19
|
-
"
|
|
18
|
+
"customer_name",
|
|
19
|
+
"order_number"
|
|
20
20
|
],
|
|
21
21
|
"ordering_fields": [
|
|
22
22
|
"created_at",
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
"format": "date-time",
|
|
135
135
|
"max_length": null,
|
|
136
136
|
"choices": null,
|
|
137
|
-
"default": "2026-01-
|
|
137
|
+
"default": "2026-01-29T14:56:45.490306+00:00",
|
|
138
138
|
"validators": [],
|
|
139
139
|
"max_digits": null,
|
|
140
140
|
"decimal_places": null,
|
|
@@ -5,22 +5,22 @@
|
|
|
5
5
|
"plural_title": "Products",
|
|
6
6
|
"primary_key_field": "id",
|
|
7
7
|
"filterable_fields": [
|
|
8
|
-
"id",
|
|
9
8
|
"name",
|
|
10
|
-
"
|
|
9
|
+
"id",
|
|
11
10
|
"price",
|
|
12
|
-
"category",
|
|
13
11
|
"created_at",
|
|
14
|
-
"
|
|
15
|
-
"in_stock"
|
|
12
|
+
"category",
|
|
13
|
+
"in_stock",
|
|
14
|
+
"description",
|
|
15
|
+
"created_by"
|
|
16
16
|
],
|
|
17
17
|
"searchable_fields": [
|
|
18
|
-
"
|
|
19
|
-
"
|
|
18
|
+
"description",
|
|
19
|
+
"name"
|
|
20
20
|
],
|
|
21
21
|
"ordering_fields": [
|
|
22
|
-
"name",
|
|
23
22
|
"price",
|
|
23
|
+
"name",
|
|
24
24
|
"created_at"
|
|
25
25
|
],
|
|
26
26
|
"properties": {
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"format": "date-time",
|
|
130
130
|
"max_length": null,
|
|
131
131
|
"choices": null,
|
|
132
|
-
"default": "2026-01-
|
|
132
|
+
"default": "2026-01-29T14:56:45.488388+00:00",
|
|
133
133
|
"validators": [],
|
|
134
134
|
"max_digits": null,
|
|
135
135
|
"decimal_places": null,
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
"plural_title": "Custom Pk Models",
|
|
6
6
|
"primary_key_field": "custom_pk",
|
|
7
7
|
"filterable_fields": [
|
|
8
|
-
"
|
|
9
|
-
"
|
|
8
|
+
"custom_pk",
|
|
9
|
+
"name"
|
|
10
10
|
],
|
|
11
11
|
"searchable_fields": [
|
|
12
12
|
"name"
|
|
13
13
|
],
|
|
14
14
|
"ordering_fields": [
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"custom_pk",
|
|
16
|
+
"name"
|
|
17
17
|
],
|
|
18
18
|
"properties": {
|
|
19
19
|
"custom_pk": {
|
|
@@ -5,21 +5,21 @@
|
|
|
5
5
|
"plural_title": "Daily Rates",
|
|
6
6
|
"primary_key_field": "id",
|
|
7
7
|
"filterable_fields": [
|
|
8
|
-
"
|
|
9
|
-
"date",
|
|
10
|
-
"rate_plan",
|
|
8
|
+
"stop_sell",
|
|
11
9
|
"min_stay_arrival",
|
|
10
|
+
"id",
|
|
12
11
|
"price",
|
|
13
|
-
"max_stay",
|
|
14
12
|
"min_stay_through",
|
|
15
|
-
"
|
|
13
|
+
"rate_plan",
|
|
16
14
|
"closed_to_arrival",
|
|
17
|
-
"
|
|
15
|
+
"max_stay",
|
|
16
|
+
"closed_to_departure",
|
|
17
|
+
"date"
|
|
18
18
|
],
|
|
19
19
|
"searchable_fields": [],
|
|
20
20
|
"ordering_fields": [
|
|
21
|
-
"
|
|
22
|
-
"
|
|
21
|
+
"date",
|
|
22
|
+
"rate_plan"
|
|
23
23
|
],
|
|
24
24
|
"properties": {
|
|
25
25
|
"id": {
|