@teincfood/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.
Files changed (62) hide show
  1. package/dist/adapters/auth.js +2 -6
  2. package/dist/adapters/business.js +2 -6
  3. package/dist/adapters/connectivity.js +6 -14
  4. package/dist/adapters/devices.js +2 -6
  5. package/dist/adapters/http.js +4 -10
  6. package/dist/adapters/image-cache.js +2 -6
  7. package/dist/adapters/kv-types.js +1 -2
  8. package/dist/adapters/kv.js +11 -24
  9. package/dist/adapters/local-node.js +3 -7
  10. package/dist/adapters/pending-orders.js +1 -4
  11. package/dist/adapters/query-keys.js +4 -7
  12. package/dist/adapters/services.js +9 -14
  13. package/dist/adapters/sqlite.js +3 -8
  14. package/dist/db/connection.js +15 -20
  15. package/dist/db/migrations.js +1 -4
  16. package/dist/db/operations.js +19 -36
  17. package/dist/index.js +40 -93
  18. package/dist/reference/api.js +7 -12
  19. package/dist/reference/events.js +25 -33
  20. package/dist/reference/operations.js +6 -14
  21. package/dist/reference/service.js +36 -39
  22. package/dist/reference/types.js +1 -2
  23. package/dist/repositories/order.repository.js +15 -18
  24. package/dist/repositories/pos.repository.js +6 -9
  25. package/dist/sync/command-builder.js +8 -12
  26. package/dist/sync/command-queue.service.js +35 -38
  27. package/dist/sync/engine.js +38 -42
  28. package/dist/sync/order-number.js +6 -11
  29. package/dist/sync/order-snapshots.service.js +19 -22
  30. package/dist/sync/pending-orders.service.js +27 -33
  31. package/dist/sync/transport-local-node.js +16 -20
  32. package/dist/sync/transport-rest.js +18 -22
  33. package/dist/sync/types.js +1 -2
  34. package/dist/sync/use-sync-reconciliation.js +37 -40
  35. package/dist/types/api/auth.api.js +1 -2
  36. package/dist/types/api/business.api.js +1 -2
  37. package/dist/types/api/conversation.api.js +1 -2
  38. package/dist/types/api/error.api.js +1 -2
  39. package/dist/types/api/fleet.api.js +1 -2
  40. package/dist/types/api/index.js +11 -27
  41. package/dist/types/api/kiosk.api.js +1 -2
  42. package/dist/types/api/menu.api.js +1 -2
  43. package/dist/types/api/pagination.js +1 -2
  44. package/dist/types/api/rider.api.js +1 -2
  45. package/dist/types/api/seller.api.d.ts +8 -0
  46. package/dist/types/api/seller.api.js +1 -2
  47. package/dist/types/api/wallet.api.js +1 -2
  48. package/dist/types/pos.types.d.ts +65 -18
  49. package/dist/types/pos.types.js +1 -5
  50. package/dist/utils/constants.js +24 -27
  51. package/dist/utils/copyToClipBoard.js +2 -7
  52. package/dist/utils/currency.js +8 -16
  53. package/dist/utils/error.js +4 -11
  54. package/dist/utils/formatCurrency.js +1 -4
  55. package/dist/utils/formatDate.js +2 -6
  56. package/dist/utils/phone.js +6 -13
  57. package/dist/utils/responsive.js +1 -4
  58. package/dist/utils/storage.js +14 -28
  59. package/dist/utils/sync-logger.js +1 -4
  60. package/dist/utils/uuid.js +4 -10
  61. package/dist/utils/validation.js +11 -24
  62. package/package.json +12 -1
@@ -1,21 +1,8 @@
1
- "use strict";
2
1
  /**
3
2
  * Validation Utilities
4
3
  * Provides schema validation for REST/WS/SSE/push payloads
5
4
  */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.validation = void 0;
8
- exports.validateEmail = validateEmail;
9
- exports.validatePhone = validatePhone;
10
- exports.validateUsername = validateUsername;
11
- exports.validatePassword = validatePassword;
12
- exports.validateOrderPayload = validateOrderPayload;
13
- exports.validateChatMessage = validateChatMessage;
14
- exports.validateEventEnvelope = validateEventEnvelope;
15
- exports.validatePromoCode = validatePromoCode;
16
- exports.validateAddress = validateAddress;
17
- exports.validatePaymentMethod = validatePaymentMethod;
18
- function validateEmail(email) {
5
+ export function validateEmail(email) {
19
6
  const errors = [];
20
7
  const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
21
8
  if (!email) {
@@ -26,7 +13,7 @@ function validateEmail(email) {
26
13
  }
27
14
  return { valid: errors.length === 0, errors };
28
15
  }
29
- function validatePhone(phone) {
16
+ export function validatePhone(phone) {
30
17
  const errors = [];
31
18
  const phoneRegex = /^\+?[1-9]\d{1,14}$/;
32
19
  if (!phone) {
@@ -37,7 +24,7 @@ function validatePhone(phone) {
37
24
  }
38
25
  return { valid: errors.length === 0, errors };
39
26
  }
40
- function validateUsername(username) {
27
+ export function validateUsername(username) {
41
28
  const errors = [];
42
29
  const usernameRegex = /^[a-zA-Z0-9_]{3,20}$/;
43
30
  if (!username) {
@@ -48,7 +35,7 @@ function validateUsername(username) {
48
35
  }
49
36
  return { valid: errors.length === 0, errors };
50
37
  }
51
- function validatePassword(password) {
38
+ export function validatePassword(password) {
52
39
  const errors = [];
53
40
  if (!password) {
54
41
  errors.push('Password is required');
@@ -69,7 +56,7 @@ function validatePassword(password) {
69
56
  }
70
57
  return { valid: errors.length === 0, errors };
71
58
  }
72
- function validateOrderPayload(payload) {
59
+ export function validateOrderPayload(payload) {
73
60
  const errors = [];
74
61
  if (!payload || typeof payload !== 'object') {
75
62
  errors.push('Order payload must be an object');
@@ -87,7 +74,7 @@ function validateOrderPayload(payload) {
87
74
  }
88
75
  return { valid: errors.length === 0, errors };
89
76
  }
90
- function validateChatMessage(payload) {
77
+ export function validateChatMessage(payload) {
91
78
  const errors = [];
92
79
  if (!payload || typeof payload !== 'object') {
93
80
  errors.push('Chat message payload must be an object');
@@ -105,7 +92,7 @@ function validateChatMessage(payload) {
105
92
  }
106
93
  return { valid: errors.length === 0, errors };
107
94
  }
108
- function validateEventEnvelope(payload) {
95
+ export function validateEventEnvelope(payload) {
109
96
  const errors = [];
110
97
  if (!payload || typeof payload !== 'object') {
111
98
  errors.push('Event envelope must be an object');
@@ -126,7 +113,7 @@ function validateEventEnvelope(payload) {
126
113
  }
127
114
  return { valid: errors.length === 0, errors };
128
115
  }
129
- function validatePromoCode(code) {
116
+ export function validatePromoCode(code) {
130
117
  const errors = [];
131
118
  const promoRegex = /^[A-Z0-9]{3,20}$/;
132
119
  if (!code) {
@@ -137,7 +124,7 @@ function validatePromoCode(code) {
137
124
  }
138
125
  return { valid: errors.length === 0, errors };
139
126
  }
140
- function validateAddress(address) {
127
+ export function validateAddress(address) {
141
128
  const errors = [];
142
129
  if (!address.street || typeof address.street !== 'string') {
143
130
  errors.push('Street address is required');
@@ -150,7 +137,7 @@ function validateAddress(address) {
150
137
  }
151
138
  return { valid: errors.length === 0, errors };
152
139
  }
153
- function validatePaymentMethod(payment) {
140
+ export function validatePaymentMethod(payment) {
154
141
  const errors = [];
155
142
  if (!payment.type || !['card', 'mobile_money'].includes(payment.type)) {
156
143
  errors.push('Payment type must be card or mobile_money');
@@ -161,7 +148,7 @@ function validatePaymentMethod(payment) {
161
148
  return { valid: errors.length === 0, errors };
162
149
  }
163
150
  // ─── Convenience object for screen-level validation ───
164
- exports.validation = {
151
+ export const validation = {
165
152
  isNotEmpty: (value) => value.trim().length > 0,
166
153
  isValid: (value, validator) => validator(value).valid,
167
154
  email: Object.assign((v) => validateEmail(v), { message: "Invalid email format" }),
package/package.json CHANGED
@@ -1,9 +1,20 @@
1
1
  {
2
2
  "name": "@teincfood/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "TeincFood shared offline-first core — types, sync engine, local DB, reference data, and repositories for mobile + desktop",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ },
13
+ "./dist/*": {
14
+ "types": "./dist/*.d.ts",
15
+ "import": "./dist/*.js"
16
+ }
17
+ },
7
18
  "files": [
8
19
  "dist"
9
20
  ],