@use-stall/core 0.0.7 → 0.0.9
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 -10
- package/dist/index.mjs +14 -10
- package/package.json +3 -6
package/dist/index.js
CHANGED
|
@@ -133,11 +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_crypto = require("crypto");
|
|
138
|
-
var uuid = () => (0, import_crypto.randomUUID)();
|
|
139
146
|
var generate_offline_id = (table) => {
|
|
140
|
-
return `stall_${table}_${
|
|
147
|
+
return `stall_${table}_${generate_uuid()}_${Date.now()}`;
|
|
141
148
|
};
|
|
142
149
|
var save_bulk_data = async (props) => {
|
|
143
150
|
await local_db.transaction("rw", props.table, async () => {
|
|
@@ -149,7 +156,7 @@ var save_bulk_data = async (props) => {
|
|
|
149
156
|
};
|
|
150
157
|
var add_to_sync_queue = async (props) => {
|
|
151
158
|
const queue_item = {
|
|
152
|
-
id:
|
|
159
|
+
id: generate_uuid(),
|
|
153
160
|
action: props.action,
|
|
154
161
|
table: props.table,
|
|
155
162
|
document_id: props.document_id,
|
|
@@ -191,7 +198,7 @@ var remove_from_sync_queue = async (id) => {
|
|
|
191
198
|
};
|
|
192
199
|
var add_sync_log = async (props) => {
|
|
193
200
|
const log = {
|
|
194
|
-
id:
|
|
201
|
+
id: generate_uuid(),
|
|
195
202
|
sync_batch_id: props.sync_batch_id,
|
|
196
203
|
table: props.table,
|
|
197
204
|
action: props.action,
|
|
@@ -3752,9 +3759,6 @@ var fulfillments = {
|
|
|
3752
3759
|
bulk_delete: bulk_delete16
|
|
3753
3760
|
};
|
|
3754
3761
|
|
|
3755
|
-
// src/services/sync/sync.service.ts
|
|
3756
|
-
var import_uuid = require("uuid");
|
|
3757
|
-
|
|
3758
3762
|
// src/services/sync/sync-dependencies.ts
|
|
3759
3763
|
var SYNC_DEPENDENCY_LAYERS = {
|
|
3760
3764
|
1: [
|
|
@@ -3985,7 +3989,7 @@ var sync_queue_item = async (props) => {
|
|
|
3985
3989
|
};
|
|
3986
3990
|
var process_sync_queue = async (props) => {
|
|
3987
3991
|
const { sdk } = props;
|
|
3988
|
-
const sync_batch_id = (
|
|
3992
|
+
const sync_batch_id = generate_uuid();
|
|
3989
3993
|
try {
|
|
3990
3994
|
const pending_items_by_table = await get_pending_sync_queue();
|
|
3991
3995
|
if (pending_items_by_table.size === 0) {
|
|
@@ -4142,7 +4146,7 @@ var trigger_sync = async (props) => {
|
|
|
4142
4146
|
} catch (error) {
|
|
4143
4147
|
console.error("Error triggering sync:", error);
|
|
4144
4148
|
return {
|
|
4145
|
-
sync_batch_id: (
|
|
4149
|
+
sync_batch_id: generate_uuid(),
|
|
4146
4150
|
total: 0,
|
|
4147
4151
|
synced: 0,
|
|
4148
4152
|
failed: 0,
|
package/dist/index.mjs
CHANGED
|
@@ -69,11 +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 { randomUUID } from "crypto";
|
|
74
|
-
var uuid = () => randomUUID();
|
|
75
82
|
var generate_offline_id = (table) => {
|
|
76
|
-
return `stall_${table}_${
|
|
83
|
+
return `stall_${table}_${generate_uuid()}_${Date.now()}`;
|
|
77
84
|
};
|
|
78
85
|
var save_bulk_data = async (props) => {
|
|
79
86
|
await local_db.transaction("rw", props.table, async () => {
|
|
@@ -85,7 +92,7 @@ var save_bulk_data = async (props) => {
|
|
|
85
92
|
};
|
|
86
93
|
var add_to_sync_queue = async (props) => {
|
|
87
94
|
const queue_item = {
|
|
88
|
-
id:
|
|
95
|
+
id: generate_uuid(),
|
|
89
96
|
action: props.action,
|
|
90
97
|
table: props.table,
|
|
91
98
|
document_id: props.document_id,
|
|
@@ -127,7 +134,7 @@ var remove_from_sync_queue = async (id) => {
|
|
|
127
134
|
};
|
|
128
135
|
var add_sync_log = async (props) => {
|
|
129
136
|
const log = {
|
|
130
|
-
id:
|
|
137
|
+
id: generate_uuid(),
|
|
131
138
|
sync_batch_id: props.sync_batch_id,
|
|
132
139
|
table: props.table,
|
|
133
140
|
action: props.action,
|
|
@@ -3688,9 +3695,6 @@ var fulfillments = {
|
|
|
3688
3695
|
bulk_delete: bulk_delete16
|
|
3689
3696
|
};
|
|
3690
3697
|
|
|
3691
|
-
// src/services/sync/sync.service.ts
|
|
3692
|
-
import { v4 as uuid2 } from "uuid";
|
|
3693
|
-
|
|
3694
3698
|
// src/services/sync/sync-dependencies.ts
|
|
3695
3699
|
var SYNC_DEPENDENCY_LAYERS = {
|
|
3696
3700
|
1: [
|
|
@@ -3921,7 +3925,7 @@ var sync_queue_item = async (props) => {
|
|
|
3921
3925
|
};
|
|
3922
3926
|
var process_sync_queue = async (props) => {
|
|
3923
3927
|
const { sdk } = props;
|
|
3924
|
-
const sync_batch_id =
|
|
3928
|
+
const sync_batch_id = generate_uuid();
|
|
3925
3929
|
try {
|
|
3926
3930
|
const pending_items_by_table = await get_pending_sync_queue();
|
|
3927
3931
|
if (pending_items_by_table.size === 0) {
|
|
@@ -4078,7 +4082,7 @@ var trigger_sync = async (props) => {
|
|
|
4078
4082
|
} catch (error) {
|
|
4079
4083
|
console.error("Error triggering sync:", error);
|
|
4080
4084
|
return {
|
|
4081
|
-
sync_batch_id:
|
|
4085
|
+
sync_batch_id: generate_uuid(),
|
|
4082
4086
|
total: 0,
|
|
4083
4087
|
synced: 0,
|
|
4084
4088
|
failed: 0,
|
package/package.json
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@use-stall/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"author": "Stall",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
|
-
"type": "commonjs",
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
7
|
"devDependencies": {
|
|
10
8
|
"@types/node": "^24.10.2",
|
|
11
9
|
"@use-stall/types": "^0.2.9",
|
|
@@ -26,7 +24,6 @@
|
|
|
26
24
|
"scripts": {
|
|
27
25
|
"build": "tsup"
|
|
28
26
|
},
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
}
|
|
27
|
+
"type": "commonjs",
|
|
28
|
+
"types": "./dist/index.d.ts"
|
|
32
29
|
}
|