@use-stall/core 0.0.15 → 0.1.1
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.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +65 -24
- package/dist/index.mjs +65 -24
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -71,25 +71,25 @@ var import_dexie = __toESM(require("dexie"));
|
|
|
71
71
|
// src/db/schema.ts
|
|
72
72
|
var schemas = {
|
|
73
73
|
connector_cache: "id",
|
|
74
|
-
sync_queue: "++id, status, timestamp, priority",
|
|
75
|
-
sync_logs: "++id, sync_batch_id, timestamp",
|
|
76
|
-
products: "++id",
|
|
77
|
-
variants: "++id",
|
|
78
|
-
collections: "++id",
|
|
79
|
-
categories: "++id",
|
|
80
|
-
inventory_levels: "++id",
|
|
81
|
-
inventory_history: "++id",
|
|
82
|
-
promotions: "++id",
|
|
83
|
-
orders: "++id",
|
|
84
|
-
order_notes: "++id",
|
|
85
|
-
refunds: "++id",
|
|
86
|
-
payment_providers: "++id",
|
|
87
|
-
payments: "++id",
|
|
88
|
-
tax_regions: "++id",
|
|
89
|
-
tax_rates: "++id",
|
|
90
|
-
customers: "++id",
|
|
91
|
-
locations: "++id",
|
|
92
|
-
fulfillments: "++id"
|
|
74
|
+
sync_queue: "++id, status, timestamp, priority, table, stall_offline_id, action, retry_count",
|
|
75
|
+
sync_logs: "++id, sync_batch_id, timestamp, table, action, status, stall_offline_id",
|
|
76
|
+
products: "++id, name, sku, created_at, updated_at, active, vendor, product_type, collection_id, category_id, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
77
|
+
variants: "++id, product_id, sku, name, created_at, updated_at, active, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
78
|
+
collections: "++id, name, created_at, updated_at, active, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
79
|
+
categories: "++id, name, created_at, updated_at, active, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
80
|
+
inventory_levels: "++id, product_id, variant_id, location_id, quantity, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
81
|
+
inventory_history: "++id, product_id, variant_id, location_id, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
82
|
+
promotions: "++id, name, type, active, start_date, end_date, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
83
|
+
orders: "++id, order_number, customer_id, location_id, status, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
84
|
+
order_notes: "++id, order_id, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
85
|
+
refunds: "++id, order_id, payment_id, status, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
86
|
+
payment_providers: "++id, name, type, active, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
87
|
+
payments: "++id, order_id, status, method, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
88
|
+
tax_regions: "++id, name, country, alpha3, alpha2, tax_inclusive, is_default, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at, metadata.stall_offline_deleted_at",
|
|
89
|
+
tax_rates: "++id, name, region_id, state, rate, type, code, compound, priority, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at, metadata.stall_offline_deleted_at",
|
|
90
|
+
customers: "++id, email, phone, name, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
91
|
+
locations: "++id, name, city, country, region, active, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
92
|
+
fulfillments: "++id, order_id, status, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at"
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
// src/db/db.ts
|
|
@@ -117,7 +117,7 @@ var is_offline = () => {
|
|
|
117
117
|
|
|
118
118
|
// src/db/helpers.ts
|
|
119
119
|
var generate_offline_id = (table) => {
|
|
120
|
-
return
|
|
120
|
+
return `${generate_uuid()}-${Date.now()}`;
|
|
121
121
|
};
|
|
122
122
|
var get_action_priority = (action) => {
|
|
123
123
|
switch (action) {
|
|
@@ -319,7 +319,9 @@ var is_syncing = false;
|
|
|
319
319
|
var replace_temporary_ids = async (props) => {
|
|
320
320
|
const { table, stall_offline_id, connector_id } = props;
|
|
321
321
|
try {
|
|
322
|
-
const existing = await local_db[table].
|
|
322
|
+
const existing = await local_db[table].filter(
|
|
323
|
+
(record) => record.metadata?.stall_offline_id === stall_offline_id || record?.stall_offline_id === stall_offline_id
|
|
324
|
+
).first();
|
|
323
325
|
if (existing) {
|
|
324
326
|
await local_db[table].update(existing.id, {
|
|
325
327
|
id: connector_id
|
|
@@ -622,7 +624,6 @@ var trigger_sync = async (props) => {
|
|
|
622
624
|
var start_sync = async (props) => {
|
|
623
625
|
const { sdk } = props;
|
|
624
626
|
if (sync_interval) {
|
|
625
|
-
console.warn("Background sync already running");
|
|
626
627
|
return;
|
|
627
628
|
}
|
|
628
629
|
console.log(
|
|
@@ -655,12 +656,50 @@ var stop_sync = () => {
|
|
|
655
656
|
console.warn("Background sync is not running");
|
|
656
657
|
}
|
|
657
658
|
};
|
|
659
|
+
var clear_core_db = async () => {
|
|
660
|
+
try {
|
|
661
|
+
const tables = [
|
|
662
|
+
"products",
|
|
663
|
+
"variants",
|
|
664
|
+
"collections",
|
|
665
|
+
"categories",
|
|
666
|
+
"tags",
|
|
667
|
+
"inventory_levels",
|
|
668
|
+
"inventory_history",
|
|
669
|
+
"promotions",
|
|
670
|
+
"orders",
|
|
671
|
+
"order_notes",
|
|
672
|
+
"refunds",
|
|
673
|
+
"payment_providers",
|
|
674
|
+
"payments",
|
|
675
|
+
"tax_regions",
|
|
676
|
+
"tax_rates",
|
|
677
|
+
"customers",
|
|
678
|
+
"locations",
|
|
679
|
+
"fulfillment_types",
|
|
680
|
+
"fulfillment_providers",
|
|
681
|
+
"fulfillments"
|
|
682
|
+
];
|
|
683
|
+
for (const table of tables) {
|
|
684
|
+
await local_db[table].clear();
|
|
685
|
+
}
|
|
686
|
+
return {
|
|
687
|
+
cleared_tables: tables.length
|
|
688
|
+
};
|
|
689
|
+
} catch (error) {
|
|
690
|
+
console.error("Error clearing local data:", error);
|
|
691
|
+
return {
|
|
692
|
+
cleared_tables: 0
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
};
|
|
658
696
|
var sync_service = {
|
|
659
697
|
get_sync_status,
|
|
660
698
|
fix_sync_queue,
|
|
661
699
|
trigger_sync,
|
|
662
700
|
start_sync,
|
|
663
|
-
stop_sync
|
|
701
|
+
stop_sync,
|
|
702
|
+
clear_core_db
|
|
664
703
|
};
|
|
665
704
|
|
|
666
705
|
// src/core/init.ts
|
|
@@ -4026,7 +4065,7 @@ var tax_rates = {
|
|
|
4026
4065
|
bulk_delete: bulk_delete14
|
|
4027
4066
|
};
|
|
4028
4067
|
|
|
4029
|
-
// src/services
|
|
4068
|
+
// src/lib/services-helpers.ts
|
|
4030
4069
|
var build_location = (data, offline_id, now) => {
|
|
4031
4070
|
return {
|
|
4032
4071
|
id: offline_id,
|
|
@@ -4074,6 +4113,8 @@ var merge_location = (existing, updates, now) => {
|
|
|
4074
4113
|
}
|
|
4075
4114
|
};
|
|
4076
4115
|
};
|
|
4116
|
+
|
|
4117
|
+
// src/services/locations.service.ts
|
|
4077
4118
|
var list15 = async (props) => {
|
|
4078
4119
|
try {
|
|
4079
4120
|
const { sdk, query } = props;
|
package/dist/index.mjs
CHANGED
|
@@ -4,25 +4,25 @@ import Dexie from "dexie";
|
|
|
4
4
|
// src/db/schema.ts
|
|
5
5
|
var schemas = {
|
|
6
6
|
connector_cache: "id",
|
|
7
|
-
sync_queue: "++id, status, timestamp, priority",
|
|
8
|
-
sync_logs: "++id, sync_batch_id, timestamp",
|
|
9
|
-
products: "++id",
|
|
10
|
-
variants: "++id",
|
|
11
|
-
collections: "++id",
|
|
12
|
-
categories: "++id",
|
|
13
|
-
inventory_levels: "++id",
|
|
14
|
-
inventory_history: "++id",
|
|
15
|
-
promotions: "++id",
|
|
16
|
-
orders: "++id",
|
|
17
|
-
order_notes: "++id",
|
|
18
|
-
refunds: "++id",
|
|
19
|
-
payment_providers: "++id",
|
|
20
|
-
payments: "++id",
|
|
21
|
-
tax_regions: "++id",
|
|
22
|
-
tax_rates: "++id",
|
|
23
|
-
customers: "++id",
|
|
24
|
-
locations: "++id",
|
|
25
|
-
fulfillments: "++id"
|
|
7
|
+
sync_queue: "++id, status, timestamp, priority, table, stall_offline_id, action, retry_count",
|
|
8
|
+
sync_logs: "++id, sync_batch_id, timestamp, table, action, status, stall_offline_id",
|
|
9
|
+
products: "++id, name, sku, created_at, updated_at, active, vendor, product_type, collection_id, category_id, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
10
|
+
variants: "++id, product_id, sku, name, created_at, updated_at, active, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
11
|
+
collections: "++id, name, created_at, updated_at, active, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
12
|
+
categories: "++id, name, created_at, updated_at, active, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
13
|
+
inventory_levels: "++id, product_id, variant_id, location_id, quantity, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
14
|
+
inventory_history: "++id, product_id, variant_id, location_id, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
15
|
+
promotions: "++id, name, type, active, start_date, end_date, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
16
|
+
orders: "++id, order_number, customer_id, location_id, status, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
17
|
+
order_notes: "++id, order_id, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
18
|
+
refunds: "++id, order_id, payment_id, status, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
19
|
+
payment_providers: "++id, name, type, active, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
20
|
+
payments: "++id, order_id, status, method, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
21
|
+
tax_regions: "++id, name, country, alpha3, alpha2, tax_inclusive, is_default, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at, metadata.stall_offline_deleted_at",
|
|
22
|
+
tax_rates: "++id, name, region_id, state, rate, type, code, compound, priority, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at, metadata.stall_offline_deleted_at",
|
|
23
|
+
customers: "++id, email, phone, name, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
24
|
+
locations: "++id, name, city, country, region, active, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at",
|
|
25
|
+
fulfillments: "++id, order_id, status, created_at, updated_at, metadata.stall_offline_id, metadata.stall_offline_created_at, metadata.stall_offline_updated_at"
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
// src/db/db.ts
|
|
@@ -50,7 +50,7 @@ var is_offline = () => {
|
|
|
50
50
|
|
|
51
51
|
// src/db/helpers.ts
|
|
52
52
|
var generate_offline_id = (table) => {
|
|
53
|
-
return
|
|
53
|
+
return `${generate_uuid()}-${Date.now()}`;
|
|
54
54
|
};
|
|
55
55
|
var get_action_priority = (action) => {
|
|
56
56
|
switch (action) {
|
|
@@ -252,7 +252,9 @@ var is_syncing = false;
|
|
|
252
252
|
var replace_temporary_ids = async (props) => {
|
|
253
253
|
const { table, stall_offline_id, connector_id } = props;
|
|
254
254
|
try {
|
|
255
|
-
const existing = await local_db[table].
|
|
255
|
+
const existing = await local_db[table].filter(
|
|
256
|
+
(record) => record.metadata?.stall_offline_id === stall_offline_id || record?.stall_offline_id === stall_offline_id
|
|
257
|
+
).first();
|
|
256
258
|
if (existing) {
|
|
257
259
|
await local_db[table].update(existing.id, {
|
|
258
260
|
id: connector_id
|
|
@@ -555,7 +557,6 @@ var trigger_sync = async (props) => {
|
|
|
555
557
|
var start_sync = async (props) => {
|
|
556
558
|
const { sdk } = props;
|
|
557
559
|
if (sync_interval) {
|
|
558
|
-
console.warn("Background sync already running");
|
|
559
560
|
return;
|
|
560
561
|
}
|
|
561
562
|
console.log(
|
|
@@ -588,12 +589,50 @@ var stop_sync = () => {
|
|
|
588
589
|
console.warn("Background sync is not running");
|
|
589
590
|
}
|
|
590
591
|
};
|
|
592
|
+
var clear_core_db = async () => {
|
|
593
|
+
try {
|
|
594
|
+
const tables = [
|
|
595
|
+
"products",
|
|
596
|
+
"variants",
|
|
597
|
+
"collections",
|
|
598
|
+
"categories",
|
|
599
|
+
"tags",
|
|
600
|
+
"inventory_levels",
|
|
601
|
+
"inventory_history",
|
|
602
|
+
"promotions",
|
|
603
|
+
"orders",
|
|
604
|
+
"order_notes",
|
|
605
|
+
"refunds",
|
|
606
|
+
"payment_providers",
|
|
607
|
+
"payments",
|
|
608
|
+
"tax_regions",
|
|
609
|
+
"tax_rates",
|
|
610
|
+
"customers",
|
|
611
|
+
"locations",
|
|
612
|
+
"fulfillment_types",
|
|
613
|
+
"fulfillment_providers",
|
|
614
|
+
"fulfillments"
|
|
615
|
+
];
|
|
616
|
+
for (const table of tables) {
|
|
617
|
+
await local_db[table].clear();
|
|
618
|
+
}
|
|
619
|
+
return {
|
|
620
|
+
cleared_tables: tables.length
|
|
621
|
+
};
|
|
622
|
+
} catch (error) {
|
|
623
|
+
console.error("Error clearing local data:", error);
|
|
624
|
+
return {
|
|
625
|
+
cleared_tables: 0
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
};
|
|
591
629
|
var sync_service = {
|
|
592
630
|
get_sync_status,
|
|
593
631
|
fix_sync_queue,
|
|
594
632
|
trigger_sync,
|
|
595
633
|
start_sync,
|
|
596
|
-
stop_sync
|
|
634
|
+
stop_sync,
|
|
635
|
+
clear_core_db
|
|
597
636
|
};
|
|
598
637
|
|
|
599
638
|
// src/core/init.ts
|
|
@@ -3959,7 +3998,7 @@ var tax_rates = {
|
|
|
3959
3998
|
bulk_delete: bulk_delete14
|
|
3960
3999
|
};
|
|
3961
4000
|
|
|
3962
|
-
// src/services
|
|
4001
|
+
// src/lib/services-helpers.ts
|
|
3963
4002
|
var build_location = (data, offline_id, now) => {
|
|
3964
4003
|
return {
|
|
3965
4004
|
id: offline_id,
|
|
@@ -4007,6 +4046,8 @@ var merge_location = (existing, updates, now) => {
|
|
|
4007
4046
|
}
|
|
4008
4047
|
};
|
|
4009
4048
|
};
|
|
4049
|
+
|
|
4050
|
+
// src/services/locations.service.ts
|
|
4010
4051
|
var list15 = async (props) => {
|
|
4011
4052
|
try {
|
|
4012
4053
|
const { sdk, query } = props;
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@use-stall/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"author": "Stall",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
7
7
|
"devDependencies": {
|
|
8
8
|
"@types/node": "^24.10.2",
|
|
9
|
-
"@use-stall/types": "^0.2.
|
|
9
|
+
"@use-stall/types": "^0.2.12",
|
|
10
10
|
"dexie": "^4.2.1",
|
|
11
11
|
"tsup": "^8.5.1",
|
|
12
12
|
"typescript": "^5.9.3"
|