@use-stall/core 0.1.0 → 0.1.2

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 CHANGED
@@ -727,6 +727,9 @@ declare const sync_service: {
727
727
  sdk: CoreConfig;
728
728
  }) => Promise<void>;
729
729
  stop_sync: () => void;
730
+ clear_core_db: () => Promise<{
731
+ cleared_tables: number;
732
+ }>;
730
733
  };
731
734
 
732
735
  interface ConnectorCacheType {
package/dist/index.d.ts CHANGED
@@ -727,6 +727,9 @@ declare const sync_service: {
727
727
  sdk: CoreConfig;
728
728
  }) => Promise<void>;
729
729
  stop_sync: () => void;
730
+ clear_core_db: () => Promise<{
731
+ cleared_tables: number;
732
+ }>;
730
733
  };
731
734
 
732
735
  interface ConnectorCacheType {
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 `stall_${table}_${generate_uuid()}_${Date.now()}`;
120
+ return `${generate_uuid()}-${Date.now()}`;
121
121
  };
122
122
  var get_action_priority = (action) => {
123
123
  switch (action) {
@@ -624,7 +624,6 @@ var trigger_sync = async (props) => {
624
624
  var start_sync = async (props) => {
625
625
  const { sdk } = props;
626
626
  if (sync_interval) {
627
- console.warn("Background sync already running");
628
627
  return;
629
628
  }
630
629
  console.log(
@@ -657,12 +656,50 @@ var stop_sync = () => {
657
656
  console.warn("Background sync is not running");
658
657
  }
659
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
+ };
660
696
  var sync_service = {
661
697
  get_sync_status,
662
698
  fix_sync_queue,
663
699
  trigger_sync,
664
700
  start_sync,
665
- stop_sync
701
+ stop_sync,
702
+ clear_core_db
666
703
  };
667
704
 
668
705
  // src/core/init.ts
@@ -4028,7 +4065,7 @@ var tax_rates = {
4028
4065
  bulk_delete: bulk_delete14
4029
4066
  };
4030
4067
 
4031
- // src/services/locations.service.ts
4068
+ // src/lib/services-helpers.ts
4032
4069
  var build_location = (data, offline_id, now) => {
4033
4070
  return {
4034
4071
  id: offline_id,
@@ -4076,6 +4113,8 @@ var merge_location = (existing, updates, now) => {
4076
4113
  }
4077
4114
  };
4078
4115
  };
4116
+
4117
+ // src/services/locations.service.ts
4079
4118
  var list15 = async (props) => {
4080
4119
  try {
4081
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 `stall_${table}_${generate_uuid()}_${Date.now()}`;
53
+ return `${generate_uuid()}-${Date.now()}`;
54
54
  };
55
55
  var get_action_priority = (action) => {
56
56
  switch (action) {
@@ -557,7 +557,6 @@ var trigger_sync = async (props) => {
557
557
  var start_sync = async (props) => {
558
558
  const { sdk } = props;
559
559
  if (sync_interval) {
560
- console.warn("Background sync already running");
561
560
  return;
562
561
  }
563
562
  console.log(
@@ -590,12 +589,50 @@ var stop_sync = () => {
590
589
  console.warn("Background sync is not running");
591
590
  }
592
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
+ };
593
629
  var sync_service = {
594
630
  get_sync_status,
595
631
  fix_sync_queue,
596
632
  trigger_sync,
597
633
  start_sync,
598
- stop_sync
634
+ stop_sync,
635
+ clear_core_db
599
636
  };
600
637
 
601
638
  // src/core/init.ts
@@ -3961,7 +3998,7 @@ var tax_rates = {
3961
3998
  bulk_delete: bulk_delete14
3962
3999
  };
3963
4000
 
3964
- // src/services/locations.service.ts
4001
+ // src/lib/services-helpers.ts
3965
4002
  var build_location = (data, offline_id, now) => {
3966
4003
  return {
3967
4004
  id: offline_id,
@@ -4009,6 +4046,8 @@ var merge_location = (existing, updates, now) => {
4009
4046
  }
4010
4047
  };
4011
4048
  };
4049
+
4050
+ // src/services/locations.service.ts
4012
4051
  var list15 = async (props) => {
4013
4052
  try {
4014
4053
  const { sdk, query } = props;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@use-stall/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
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.11",
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"