@use-stall/core 0.0.8 → 0.0.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.
- package/dist/index.js +14 -9
- package/dist/index.mjs +14 -9
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -133,10 +133,18 @@ var getAdapter = async (sdk, force) => {
|
|
|
133
133
|
return module2;
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
+
// src/lib/utils.ts
|
|
137
|
+
var generate_uuid = () => {
|
|
138
|
+
return "xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
139
|
+
const r = Math.random() * 16 | 0;
|
|
140
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
141
|
+
return v.toString(16);
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
|
|
136
145
|
// src/db/helpers.ts
|
|
137
|
-
var import_uuid = require("uuid");
|
|
138
146
|
var generate_offline_id = (table) => {
|
|
139
|
-
return `stall_${table}_${(
|
|
147
|
+
return `stall_${table}_${generate_uuid()}_${Date.now()}`;
|
|
140
148
|
};
|
|
141
149
|
var save_bulk_data = async (props) => {
|
|
142
150
|
await local_db.transaction("rw", props.table, async () => {
|
|
@@ -148,7 +156,7 @@ var save_bulk_data = async (props) => {
|
|
|
148
156
|
};
|
|
149
157
|
var add_to_sync_queue = async (props) => {
|
|
150
158
|
const queue_item = {
|
|
151
|
-
id: (
|
|
159
|
+
id: generate_uuid(),
|
|
152
160
|
action: props.action,
|
|
153
161
|
table: props.table,
|
|
154
162
|
document_id: props.document_id,
|
|
@@ -190,7 +198,7 @@ var remove_from_sync_queue = async (id) => {
|
|
|
190
198
|
};
|
|
191
199
|
var add_sync_log = async (props) => {
|
|
192
200
|
const log = {
|
|
193
|
-
id: (
|
|
201
|
+
id: generate_uuid(),
|
|
194
202
|
sync_batch_id: props.sync_batch_id,
|
|
195
203
|
table: props.table,
|
|
196
204
|
action: props.action,
|
|
@@ -3751,9 +3759,6 @@ var fulfillments = {
|
|
|
3751
3759
|
bulk_delete: bulk_delete16
|
|
3752
3760
|
};
|
|
3753
3761
|
|
|
3754
|
-
// src/services/sync/sync.service.ts
|
|
3755
|
-
var import_uuid2 = require("uuid");
|
|
3756
|
-
|
|
3757
3762
|
// src/services/sync/sync-dependencies.ts
|
|
3758
3763
|
var SYNC_DEPENDENCY_LAYERS = {
|
|
3759
3764
|
1: [
|
|
@@ -3984,7 +3989,7 @@ var sync_queue_item = async (props) => {
|
|
|
3984
3989
|
};
|
|
3985
3990
|
var process_sync_queue = async (props) => {
|
|
3986
3991
|
const { sdk } = props;
|
|
3987
|
-
const sync_batch_id = (
|
|
3992
|
+
const sync_batch_id = generate_uuid();
|
|
3988
3993
|
try {
|
|
3989
3994
|
const pending_items_by_table = await get_pending_sync_queue();
|
|
3990
3995
|
if (pending_items_by_table.size === 0) {
|
|
@@ -4141,7 +4146,7 @@ var trigger_sync = async (props) => {
|
|
|
4141
4146
|
} catch (error) {
|
|
4142
4147
|
console.error("Error triggering sync:", error);
|
|
4143
4148
|
return {
|
|
4144
|
-
sync_batch_id: (
|
|
4149
|
+
sync_batch_id: generate_uuid(),
|
|
4145
4150
|
total: 0,
|
|
4146
4151
|
synced: 0,
|
|
4147
4152
|
failed: 0,
|
package/dist/index.mjs
CHANGED
|
@@ -69,10 +69,18 @@ var getAdapter = async (sdk, force) => {
|
|
|
69
69
|
return module;
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
// src/lib/utils.ts
|
|
73
|
+
var generate_uuid = () => {
|
|
74
|
+
return "xxxxxxxx-xxxx-xxxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
75
|
+
const r = Math.random() * 16 | 0;
|
|
76
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
77
|
+
return v.toString(16);
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
72
81
|
// src/db/helpers.ts
|
|
73
|
-
import { v4 as uuid } from "uuid";
|
|
74
82
|
var generate_offline_id = (table) => {
|
|
75
|
-
return `stall_${table}_${
|
|
83
|
+
return `stall_${table}_${generate_uuid()}_${Date.now()}`;
|
|
76
84
|
};
|
|
77
85
|
var save_bulk_data = async (props) => {
|
|
78
86
|
await local_db.transaction("rw", props.table, async () => {
|
|
@@ -84,7 +92,7 @@ var save_bulk_data = async (props) => {
|
|
|
84
92
|
};
|
|
85
93
|
var add_to_sync_queue = async (props) => {
|
|
86
94
|
const queue_item = {
|
|
87
|
-
id:
|
|
95
|
+
id: generate_uuid(),
|
|
88
96
|
action: props.action,
|
|
89
97
|
table: props.table,
|
|
90
98
|
document_id: props.document_id,
|
|
@@ -126,7 +134,7 @@ var remove_from_sync_queue = async (id) => {
|
|
|
126
134
|
};
|
|
127
135
|
var add_sync_log = async (props) => {
|
|
128
136
|
const log = {
|
|
129
|
-
id:
|
|
137
|
+
id: generate_uuid(),
|
|
130
138
|
sync_batch_id: props.sync_batch_id,
|
|
131
139
|
table: props.table,
|
|
132
140
|
action: props.action,
|
|
@@ -3687,9 +3695,6 @@ var fulfillments = {
|
|
|
3687
3695
|
bulk_delete: bulk_delete16
|
|
3688
3696
|
};
|
|
3689
3697
|
|
|
3690
|
-
// src/services/sync/sync.service.ts
|
|
3691
|
-
import { v4 as uuid2 } from "uuid";
|
|
3692
|
-
|
|
3693
3698
|
// src/services/sync/sync-dependencies.ts
|
|
3694
3699
|
var SYNC_DEPENDENCY_LAYERS = {
|
|
3695
3700
|
1: [
|
|
@@ -3920,7 +3925,7 @@ var sync_queue_item = async (props) => {
|
|
|
3920
3925
|
};
|
|
3921
3926
|
var process_sync_queue = async (props) => {
|
|
3922
3927
|
const { sdk } = props;
|
|
3923
|
-
const sync_batch_id =
|
|
3928
|
+
const sync_batch_id = generate_uuid();
|
|
3924
3929
|
try {
|
|
3925
3930
|
const pending_items_by_table = await get_pending_sync_queue();
|
|
3926
3931
|
if (pending_items_by_table.size === 0) {
|
|
@@ -4077,7 +4082,7 @@ var trigger_sync = async (props) => {
|
|
|
4077
4082
|
} catch (error) {
|
|
4078
4083
|
console.error("Error triggering sync:", error);
|
|
4079
4084
|
return {
|
|
4080
|
-
sync_batch_id:
|
|
4085
|
+
sync_batch_id: generate_uuid(),
|
|
4081
4086
|
total: 0,
|
|
4082
4087
|
synced: 0,
|
|
4083
4088
|
failed: 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@use-stall/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"author": "Stall",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -9,8 +9,7 @@
|
|
|
9
9
|
"@use-stall/types": "^0.2.9",
|
|
10
10
|
"dexie": "^4.2.1",
|
|
11
11
|
"tsup": "^8.5.1",
|
|
12
|
-
"typescript": "^5.9.3"
|
|
13
|
-
"uuid": "^13.0.0"
|
|
12
|
+
"typescript": "^5.9.3"
|
|
14
13
|
},
|
|
15
14
|
"description": "Stall core package with all the utilities needed to access the Stall API",
|
|
16
15
|
"homepage": "https://github.com/use-stall/core",
|