@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.
- package/dist/adapters/auth.js +2 -6
- package/dist/adapters/business.js +2 -6
- package/dist/adapters/connectivity.js +6 -14
- package/dist/adapters/devices.js +2 -6
- package/dist/adapters/http.js +4 -10
- package/dist/adapters/image-cache.js +2 -6
- package/dist/adapters/kv-types.js +1 -2
- package/dist/adapters/kv.js +11 -24
- package/dist/adapters/local-node.js +3 -7
- package/dist/adapters/pending-orders.js +1 -4
- package/dist/adapters/query-keys.js +4 -7
- package/dist/adapters/services.js +9 -14
- package/dist/adapters/sqlite.js +3 -8
- package/dist/db/connection.js +15 -20
- package/dist/db/migrations.js +1 -4
- package/dist/db/operations.js +19 -36
- package/dist/index.js +40 -93
- package/dist/reference/api.js +7 -12
- package/dist/reference/events.js +25 -33
- package/dist/reference/operations.js +6 -14
- package/dist/reference/service.js +36 -39
- package/dist/reference/types.js +1 -2
- package/dist/repositories/order.repository.js +15 -18
- package/dist/repositories/pos.repository.js +6 -9
- package/dist/sync/command-builder.js +8 -12
- package/dist/sync/command-queue.service.js +35 -38
- package/dist/sync/engine.js +38 -42
- package/dist/sync/order-number.js +6 -11
- package/dist/sync/order-snapshots.service.js +19 -22
- package/dist/sync/pending-orders.service.js +27 -33
- package/dist/sync/transport-local-node.js +16 -20
- package/dist/sync/transport-rest.js +18 -22
- package/dist/sync/types.js +1 -2
- package/dist/sync/use-sync-reconciliation.js +37 -40
- package/dist/types/api/auth.api.js +1 -2
- package/dist/types/api/business.api.js +1 -2
- package/dist/types/api/conversation.api.js +1 -2
- package/dist/types/api/error.api.js +1 -2
- package/dist/types/api/fleet.api.js +1 -2
- package/dist/types/api/index.js +11 -27
- package/dist/types/api/kiosk.api.js +1 -2
- package/dist/types/api/menu.api.js +1 -2
- package/dist/types/api/pagination.js +1 -2
- package/dist/types/api/rider.api.js +1 -2
- package/dist/types/api/seller.api.d.ts +8 -0
- package/dist/types/api/seller.api.js +1 -2
- package/dist/types/api/wallet.api.js +1 -2
- package/dist/types/pos.types.d.ts +65 -18
- package/dist/types/pos.types.js +1 -5
- package/dist/utils/constants.js +24 -27
- package/dist/utils/copyToClipBoard.js +2 -7
- package/dist/utils/currency.js +8 -16
- package/dist/utils/error.js +4 -11
- package/dist/utils/formatCurrency.js +1 -4
- package/dist/utils/formatDate.js +2 -6
- package/dist/utils/phone.js +6 -13
- package/dist/utils/responsive.js +1 -4
- package/dist/utils/storage.js +14 -28
- package/dist/utils/sync-logger.js +1 -4
- package/dist/utils/uuid.js +4 -10
- package/dist/utils/validation.js +11 -24
- package/package.json +12 -1
package/dist/types/api/index.js
CHANGED
|
@@ -1,27 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./pagination"), exports);
|
|
18
|
-
__exportStar(require("./auth.api"), exports);
|
|
19
|
-
__exportStar(require("./rider.api"), exports);
|
|
20
|
-
__exportStar(require("./seller.api"), exports);
|
|
21
|
-
__exportStar(require("./fleet.api"), exports);
|
|
22
|
-
__exportStar(require("./kiosk.api"), exports);
|
|
23
|
-
__exportStar(require("./menu.api"), exports);
|
|
24
|
-
__exportStar(require("./business.api"), exports);
|
|
25
|
-
__exportStar(require("./wallet.api"), exports);
|
|
26
|
-
__exportStar(require("./conversation.api"), exports);
|
|
27
|
-
__exportStar(require("./error.api"), exports);
|
|
1
|
+
export * from './pagination';
|
|
2
|
+
export * from './auth.api';
|
|
3
|
+
export * from './rider.api';
|
|
4
|
+
export * from './seller.api';
|
|
5
|
+
export * from './fleet.api';
|
|
6
|
+
export * from './kiosk.api';
|
|
7
|
+
export * from './menu.api';
|
|
8
|
+
export * from './business.api';
|
|
9
|
+
export * from './wallet.api';
|
|
10
|
+
export * from './conversation.api';
|
|
11
|
+
export * from './error.api';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -108,6 +108,14 @@ export interface SellerOrder {
|
|
|
108
108
|
user: OrderUser | null;
|
|
109
109
|
items: OrderItem[];
|
|
110
110
|
inserted_at: string;
|
|
111
|
+
rider?: {
|
|
112
|
+
id: string;
|
|
113
|
+
name: string | null;
|
|
114
|
+
rider_number: string | null;
|
|
115
|
+
avatar_url: string | null;
|
|
116
|
+
} | null;
|
|
117
|
+
merchant_handover_confirmed_at?: string | null;
|
|
118
|
+
rider_pickup_confirmed_at?: string | null;
|
|
111
119
|
}
|
|
112
120
|
export interface SellerOrderDetail extends SellerOrder {
|
|
113
121
|
notes: string | null;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,33 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
import type { MenuItem, MenuItemVariantResponse } from "./api/menu.api";
|
|
2
|
+
import type { SellerOrder, OrderItem } from "./api/seller.api";
|
|
3
|
+
import type { OrderTaxLine } from "./api/seller.api";
|
|
4
|
+
export type POSOrderType = "takeout" | "dine_in";
|
|
5
|
+
export type POSPaymentMethod = "cash" | "mobile_money";
|
|
6
|
+
export interface POSSelectedAddon {
|
|
7
|
+
addon_id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
price_minor: number;
|
|
10
|
+
}
|
|
11
|
+
export interface POSCartItem {
|
|
12
|
+
id: string;
|
|
13
|
+
menu_item: MenuItem;
|
|
14
|
+
quantity: number;
|
|
15
|
+
selected_variant: MenuItemVariantResponse | null;
|
|
16
|
+
selected_addons: POSSelectedAddon[];
|
|
17
|
+
notes: string;
|
|
18
|
+
unit_price_minor: number;
|
|
19
|
+
}
|
|
20
|
+
export interface POSCartState {
|
|
21
|
+
items: POSCartItem[];
|
|
22
|
+
subtotal_minor: number;
|
|
23
|
+
item_count: number;
|
|
24
|
+
}
|
|
25
|
+
export interface POSCheckoutForm {
|
|
26
|
+
customer_name: string;
|
|
27
|
+
customer_phone: string;
|
|
28
|
+
order_type: POSOrderType;
|
|
29
|
+
pos_payment_method: POSPaymentMethod;
|
|
30
|
+
}
|
|
31
|
+
/** Matches backend calculate_items input — server ignores extra keys */
|
|
32
|
+
export interface POSOrderItemRequest {
|
|
5
33
|
menu_item_id: string;
|
|
6
34
|
quantity: number;
|
|
7
|
-
|
|
35
|
+
variant_id?: string;
|
|
36
|
+
addon_ids?: string[];
|
|
8
37
|
}
|
|
9
38
|
export interface POSOrderCreateRequest {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
39
|
+
order_type: POSOrderType;
|
|
40
|
+
customer_name: string;
|
|
41
|
+
customer_phone: string;
|
|
42
|
+
pos_payment_method: POSPaymentMethod;
|
|
43
|
+
items: POSOrderItemRequest[];
|
|
44
|
+
notes?: string;
|
|
45
|
+
/** Client-generated command id for offline idempotency */
|
|
17
46
|
command_id?: string;
|
|
47
|
+
/** Locally allocated order number when created offline */
|
|
18
48
|
local_order_number?: string;
|
|
19
49
|
[key: string]: unknown;
|
|
20
50
|
}
|
|
21
51
|
export interface POSOrderPreviewRequest {
|
|
22
|
-
items:
|
|
23
|
-
order_type
|
|
52
|
+
items: POSOrderItemRequest[];
|
|
53
|
+
order_type?: POSOrderType;
|
|
24
54
|
customer_name?: string;
|
|
25
55
|
[key: string]: unknown;
|
|
26
56
|
}
|
|
27
|
-
export interface
|
|
28
|
-
total_minor: number;
|
|
57
|
+
export interface POSPricing {
|
|
29
58
|
subtotal_minor: number;
|
|
30
|
-
|
|
59
|
+
discounted_subtotal_minor: number;
|
|
31
60
|
delivery_fee_minor: number;
|
|
32
|
-
|
|
61
|
+
tax_minor: number;
|
|
62
|
+
tip_minor: number;
|
|
63
|
+
discount_minor: number;
|
|
64
|
+
total_minor: number;
|
|
65
|
+
currency_code: string;
|
|
66
|
+
promo_code?: string | null;
|
|
67
|
+
tax_lines: OrderTaxLine[];
|
|
68
|
+
}
|
|
69
|
+
export interface POSOrderPreviewResponse {
|
|
70
|
+
data: POSPricing;
|
|
71
|
+
}
|
|
72
|
+
export interface POSOrderCreateResponse {
|
|
73
|
+
data: SellerOrder;
|
|
74
|
+
}
|
|
75
|
+
export interface POSOrderItem {
|
|
76
|
+
menu_item_id: string;
|
|
77
|
+
quantity: number;
|
|
78
|
+
addons?: unknown[];
|
|
33
79
|
}
|
|
80
|
+
export type { SellerOrder, OrderItem };
|
package/dist/types/pos.types.js
CHANGED
package/dist/utils/constants.js
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Application-wide constants — plain config, no expo dependencies.
|
|
4
3
|
* Values can be overridden via createTeincCore config (future).
|
|
5
4
|
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.DEFAULTS = exports.appVersion = exports.CLOUD_COMMAND_TIMEOUT_MS = exports.DEFAULT_PAGE_SIZE = exports.OTP_RESEND_DELAY_SECONDS = exports.OTP_LENGTH = exports.CHAT_CONFIG = exports.CHAT_STORAGE_KEYS = exports.STORAGE_KEYS = exports.APP_VERSION = exports.APP_NAME = exports.WS_BASE_URL = exports.API_BASE_URL = void 0;
|
|
8
5
|
/** Base URL for the API — will be swapped per environment */
|
|
9
|
-
|
|
6
|
+
export const API_BASE_URL = process.env.EXPO_PUBLIC_API_URL ??
|
|
10
7
|
process.env.API_URL ??
|
|
11
8
|
"http://localhost:4000/api/v1";
|
|
12
9
|
/** WebSocket URL for Phoenix Channels */
|
|
13
|
-
|
|
10
|
+
export const WS_BASE_URL = process.env.EXPO_PUBLIC_WS_URL ??
|
|
14
11
|
process.env.WS_URL ??
|
|
15
12
|
"ws://localhost:4000";
|
|
16
13
|
/** App metadata */
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
export const APP_NAME = "Teinc Food Business";
|
|
15
|
+
export const APP_VERSION = "1.0.0";
|
|
19
16
|
/** Async storage keys */
|
|
20
|
-
|
|
17
|
+
export const STORAGE_KEYS = {
|
|
21
18
|
AUTH_TOKEN: "auth_token",
|
|
22
19
|
REFRESH_TOKEN: "refresh_token",
|
|
23
20
|
USER_PROFILE: "user_profile",
|
|
@@ -29,12 +26,12 @@ exports.STORAGE_KEYS = {
|
|
|
29
26
|
PRINTER_SETTINGS: "printer_settings",
|
|
30
27
|
};
|
|
31
28
|
/** Chat storage keys */
|
|
32
|
-
|
|
29
|
+
export const CHAT_STORAGE_KEYS = {
|
|
33
30
|
MESSAGES: "chat_messages",
|
|
34
31
|
OUTBOX: "chat_outbox",
|
|
35
32
|
};
|
|
36
33
|
/** Chat configuration */
|
|
37
|
-
|
|
34
|
+
export const CHAT_CONFIG = {
|
|
38
35
|
HEARTBEAT_INTERVAL_MS: 15000,
|
|
39
36
|
HEARTBEAT_TIMEOUT_MS: 10000,
|
|
40
37
|
RECONNECT_BASE_DELAY_MS: 1000,
|
|
@@ -44,29 +41,29 @@ exports.CHAT_CONFIG = {
|
|
|
44
41
|
MESSAGE_PAGE_SIZE: 50,
|
|
45
42
|
};
|
|
46
43
|
/** OTP configuration */
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
export const OTP_LENGTH = 4;
|
|
45
|
+
export const OTP_RESEND_DELAY_SECONDS = 60;
|
|
49
46
|
/** Pagination defaults */
|
|
50
|
-
|
|
47
|
+
export const DEFAULT_PAGE_SIZE = 20;
|
|
51
48
|
/**
|
|
52
49
|
* Max time the Sync Engine waits for a cloud command before treating the cloud
|
|
53
50
|
* as unreachable and falling back to the Local Node or the offline outbox.
|
|
54
51
|
* Keeps the terminal responsive (fast) even when the internet is slow.
|
|
55
52
|
*/
|
|
56
|
-
|
|
53
|
+
export const CLOUD_COMMAND_TIMEOUT_MS = 2500;
|
|
57
54
|
// Expo version removed; expose static version for now
|
|
58
|
-
|
|
55
|
+
export const appVersion = APP_VERSION;
|
|
59
56
|
/** Default config bundle for createTeincCore overrides */
|
|
60
|
-
|
|
61
|
-
API_BASE_URL
|
|
62
|
-
WS_BASE_URL
|
|
63
|
-
APP_NAME
|
|
64
|
-
APP_VERSION
|
|
65
|
-
STORAGE_KEYS
|
|
66
|
-
CHAT_STORAGE_KEYS
|
|
67
|
-
CHAT_CONFIG
|
|
68
|
-
OTP_LENGTH
|
|
69
|
-
OTP_RESEND_DELAY_SECONDS
|
|
70
|
-
DEFAULT_PAGE_SIZE
|
|
71
|
-
CLOUD_COMMAND_TIMEOUT_MS
|
|
57
|
+
export const DEFAULTS = {
|
|
58
|
+
API_BASE_URL,
|
|
59
|
+
WS_BASE_URL,
|
|
60
|
+
APP_NAME,
|
|
61
|
+
APP_VERSION,
|
|
62
|
+
STORAGE_KEYS,
|
|
63
|
+
CHAT_STORAGE_KEYS,
|
|
64
|
+
CHAT_CONFIG,
|
|
65
|
+
OTP_LENGTH,
|
|
66
|
+
OTP_RESEND_DELAY_SECONDS,
|
|
67
|
+
DEFAULT_PAGE_SIZE,
|
|
68
|
+
CLOUD_COMMAND_TIMEOUT_MS,
|
|
72
69
|
};
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Clipboard helper — no-op stub in core. Host apps inject real clipboard.
|
|
4
3
|
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.copyToClipboard = void 0;
|
|
7
|
-
exports.setClipboardImpl = setClipboardImpl;
|
|
8
4
|
let clipboardImpl = null;
|
|
9
|
-
function setClipboardImpl(fn) {
|
|
5
|
+
export function setClipboardImpl(fn) {
|
|
10
6
|
clipboardImpl = fn;
|
|
11
7
|
}
|
|
12
|
-
const copyToClipboard = async (text) => {
|
|
8
|
+
export const copyToClipboard = async (text) => {
|
|
13
9
|
if (clipboardImpl) {
|
|
14
10
|
await clipboardImpl(text);
|
|
15
11
|
return;
|
|
@@ -20,4 +16,3 @@ const copyToClipboard = async (text) => {
|
|
|
20
16
|
}
|
|
21
17
|
// fallback: no-op
|
|
22
18
|
};
|
|
23
|
-
exports.copyToClipboard = copyToClipboard;
|
package/dist/utils/currency.js
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Currency Utility — no RN/store dependencies.
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
exports.DEFAULT_CURRENCY = void 0;
|
|
7
|
-
exports.getCurrencySymbol = getCurrencySymbol;
|
|
8
|
-
exports.formatPrice = formatPrice;
|
|
9
|
-
exports.formatPriceFromMinor = formatPriceFromMinor;
|
|
10
|
-
exports.useCurrency = useCurrency;
|
|
11
|
-
exports.useCurrencySymbol = useCurrencySymbol;
|
|
12
|
-
exports.DEFAULT_CURRENCY = "GHS";
|
|
4
|
+
export const DEFAULT_CURRENCY = "GHS";
|
|
13
5
|
const CURRENCY_SYMBOLS = {
|
|
14
6
|
GHS: "GH₵",
|
|
15
7
|
USD: "$",
|
|
@@ -18,20 +10,20 @@ const CURRENCY_SYMBOLS = {
|
|
|
18
10
|
EUR: "€",
|
|
19
11
|
GBP: "£",
|
|
20
12
|
};
|
|
21
|
-
function getCurrencySymbol(currency) {
|
|
13
|
+
export function getCurrencySymbol(currency) {
|
|
22
14
|
return CURRENCY_SYMBOLS[currency] || currency;
|
|
23
15
|
}
|
|
24
|
-
function formatPrice(amount, currency =
|
|
16
|
+
export function formatPrice(amount, currency = DEFAULT_CURRENCY) {
|
|
25
17
|
return `${getCurrencySymbol(currency)}${amount.toFixed(2)}`;
|
|
26
18
|
}
|
|
27
|
-
function formatPriceFromMinor(amountMinor, currency =
|
|
19
|
+
export function formatPriceFromMinor(amountMinor, currency = DEFAULT_CURRENCY) {
|
|
28
20
|
const amount = amountMinor / 100;
|
|
29
21
|
return formatPrice(amount, currency);
|
|
30
22
|
}
|
|
31
23
|
// Compatibility hooks — return default when no location adapter injected
|
|
32
|
-
function useCurrency() {
|
|
33
|
-
return
|
|
24
|
+
export function useCurrency() {
|
|
25
|
+
return DEFAULT_CURRENCY;
|
|
34
26
|
}
|
|
35
|
-
function useCurrencySymbol() {
|
|
36
|
-
return getCurrencySymbol(
|
|
27
|
+
export function useCurrencySymbol() {
|
|
28
|
+
return getCurrencySymbol(DEFAULT_CURRENCY);
|
|
37
29
|
}
|
package/dist/utils/error.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ApiError = void 0;
|
|
4
|
-
exports.extractFromResponseBody = extractFromResponseBody;
|
|
5
|
-
exports.extractApiErrorMessage = extractApiErrorMessage;
|
|
6
|
-
exports.extractApiErrorCode = extractApiErrorCode;
|
|
7
|
-
function extractFromResponseBody(data) {
|
|
1
|
+
export function extractFromResponseBody(data) {
|
|
8
2
|
const errorField = data.error;
|
|
9
3
|
if (errorField && typeof errorField === "object") {
|
|
10
4
|
const msg = errorField.message;
|
|
@@ -24,7 +18,7 @@ function extractFromResponseBody(data) {
|
|
|
24
18
|
}
|
|
25
19
|
return null;
|
|
26
20
|
}
|
|
27
|
-
function extractApiErrorMessage(error) {
|
|
21
|
+
export function extractApiErrorMessage(error) {
|
|
28
22
|
if (typeof error === "string")
|
|
29
23
|
return error;
|
|
30
24
|
if (!error || typeof error !== "object")
|
|
@@ -41,7 +35,7 @@ function extractApiErrorMessage(error) {
|
|
|
41
35
|
}
|
|
42
36
|
return "An unexpected error occurred";
|
|
43
37
|
}
|
|
44
|
-
function extractApiErrorCode(error) {
|
|
38
|
+
export function extractApiErrorCode(error) {
|
|
45
39
|
if (!error || typeof error !== "object")
|
|
46
40
|
return undefined;
|
|
47
41
|
const err = error;
|
|
@@ -69,5 +63,4 @@ function extractApiErrorCode(error) {
|
|
|
69
63
|
return undefined;
|
|
70
64
|
}
|
|
71
65
|
// Re-export ApiError from http adapter for compatibility
|
|
72
|
-
|
|
73
|
-
Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return http_1.ApiError; } });
|
|
66
|
+
export { ApiError } from "../adapters/http";
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Format a number as a currency string.
|
|
4
3
|
*/
|
|
5
|
-
|
|
6
|
-
exports.formatCurrency = formatCurrency;
|
|
7
|
-
function formatCurrency(amount, currency = "GHS") {
|
|
4
|
+
export function formatCurrency(amount, currency = "GHS") {
|
|
8
5
|
const amountMinor = Math.round(amount * 100);
|
|
9
6
|
// Simple region formatting — host apps can inject getRegionConfig via adapter if needed
|
|
10
7
|
const symbolMap = {
|
package/dist/utils/formatDate.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatDate = formatDate;
|
|
4
|
-
exports.formatRelativeTime = formatRelativeTime;
|
|
5
1
|
/**
|
|
6
2
|
* Format an ISO date string into a human-readable format.
|
|
7
3
|
*/
|
|
8
|
-
function formatDate(isoString, style = 'short') {
|
|
4
|
+
export function formatDate(isoString, style = 'short') {
|
|
9
5
|
const date = new Date(isoString);
|
|
10
6
|
if (style === 'long') {
|
|
11
7
|
return date.toLocaleDateString('en-US', {
|
|
@@ -23,7 +19,7 @@ function formatDate(isoString, style = 'short') {
|
|
|
23
19
|
/**
|
|
24
20
|
* Format a date as a relative time string (e.g., "20 min ago").
|
|
25
21
|
*/
|
|
26
|
-
function formatRelativeTime(isoString) {
|
|
22
|
+
export function formatRelativeTime(isoString) {
|
|
27
23
|
const now = Date.now();
|
|
28
24
|
const then = new Date(isoString).getTime();
|
|
29
25
|
const diffMs = now - then;
|
package/dist/utils/phone.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PHONE_COUNTRIES = void 0;
|
|
4
|
-
exports.getDialCodeFromCountry = getDialCodeFromCountry;
|
|
5
|
-
exports.getCountryOption = getCountryOption;
|
|
6
|
-
exports.normalizePhoneForCountry = normalizePhoneForCountry;
|
|
7
|
-
exports.isLikelyE164 = isLikelyE164;
|
|
8
|
-
exports.PHONE_COUNTRIES = [
|
|
1
|
+
export const PHONE_COUNTRIES = [
|
|
9
2
|
{ iso: 'GH', name: 'Ghana', dialCode: '+233' },
|
|
10
3
|
{ iso: 'NG', name: 'Nigeria', dialCode: '+234' },
|
|
11
4
|
{ iso: 'KE', name: 'Kenya', dialCode: '+254' },
|
|
@@ -40,17 +33,17 @@ const COUNTRY_DIAL_CODE_BY_ISO = {
|
|
|
40
33
|
function digitsOnly(value) {
|
|
41
34
|
return value.replace(/\D/g, '');
|
|
42
35
|
}
|
|
43
|
-
function getDialCodeFromCountry(countryCode) {
|
|
36
|
+
export function getDialCodeFromCountry(countryCode) {
|
|
44
37
|
if (!countryCode)
|
|
45
38
|
return null;
|
|
46
39
|
return COUNTRY_DIAL_CODE_BY_ISO[countryCode.trim().toUpperCase()] || null;
|
|
47
40
|
}
|
|
48
|
-
function getCountryOption(iso) {
|
|
41
|
+
export function getCountryOption(iso) {
|
|
49
42
|
if (!iso)
|
|
50
43
|
return null;
|
|
51
|
-
return
|
|
44
|
+
return PHONE_COUNTRIES.find((country) => country.iso === iso.trim().toUpperCase()) || null;
|
|
52
45
|
}
|
|
53
|
-
function normalizePhoneForCountry(rawPhone, countryCode) {
|
|
46
|
+
export function normalizePhoneForCountry(rawPhone, countryCode) {
|
|
54
47
|
const input = rawPhone.trim();
|
|
55
48
|
if (!input)
|
|
56
49
|
return null;
|
|
@@ -66,6 +59,6 @@ function normalizePhoneForCountry(rawPhone, countryCode) {
|
|
|
66
59
|
return null;
|
|
67
60
|
return `${dialCode}${localDigits}`;
|
|
68
61
|
}
|
|
69
|
-
function isLikelyE164(phone) {
|
|
62
|
+
export function isLikelyE164(phone) {
|
|
70
63
|
return /^\+[1-9]\d{7,14}$/.test(phone);
|
|
71
64
|
}
|
package/dist/utils/responsive.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Responsive helper — plain, no react-native.
|
|
4
3
|
* Host apps with RN can override via adapter; core provides window-based fallback.
|
|
5
4
|
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.useResponsive = useResponsive;
|
|
8
5
|
function getWindowSize() {
|
|
9
6
|
if (typeof window !== "undefined") {
|
|
10
7
|
return { width: window.innerWidth, height: window.innerHeight };
|
|
11
8
|
}
|
|
12
9
|
return { width: 1024, height: 768 };
|
|
13
10
|
}
|
|
14
|
-
function useResponsive() {
|
|
11
|
+
export function useResponsive() {
|
|
15
12
|
const { width, height } = getWindowSize();
|
|
16
13
|
const isTablet = width >= 768;
|
|
17
14
|
const isLandscape = width > height;
|
package/dist/utils/storage.js
CHANGED
|
@@ -1,48 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Storage facade — re-exports KV adapter.
|
|
4
3
|
* Provides async JSON helpers and a zustand-compatible storage shim.
|
|
5
4
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.setItemAsync = setItemAsync;
|
|
10
|
-
exports.removeItemAsync = removeItemAsync;
|
|
11
|
-
var kv_1 = require("../adapters/kv");
|
|
12
|
-
Object.defineProperty(exports, "getItem", { enumerable: true, get: function () { return kv_1.getItem; } });
|
|
13
|
-
Object.defineProperty(exports, "setItem", { enumerable: true, get: function () { return kv_1.setItem; } });
|
|
14
|
-
Object.defineProperty(exports, "removeItem", { enumerable: true, get: function () { return kv_1.removeItem; } });
|
|
15
|
-
Object.defineProperty(exports, "kvGetItem", { enumerable: true, get: function () { return kv_1.kvGetItem; } });
|
|
16
|
-
Object.defineProperty(exports, "kvSetItem", { enumerable: true, get: function () { return kv_1.kvSetItem; } });
|
|
17
|
-
Object.defineProperty(exports, "kvRemoveItem", { enumerable: true, get: function () { return kv_1.kvRemoveItem; } });
|
|
18
|
-
Object.defineProperty(exports, "setKVDriver", { enumerable: true, get: function () { return kv_1.setKVDriver; } });
|
|
19
|
-
Object.defineProperty(exports, "getKVDriver", { enumerable: true, get: function () { return kv_1.getKVDriver; } });
|
|
20
|
-
const kv_2 = require("../adapters/kv");
|
|
21
|
-
const kv_3 = require("../adapters/kv");
|
|
5
|
+
export { getItem, setItem, removeItem, kvGetItem, kvSetItem, kvRemoveItem, setKVDriver, getKVDriver, } from "../adapters/kv";
|
|
6
|
+
import { kvGetItem, kvSetItem, kvRemoveItem } from "../adapters/kv";
|
|
7
|
+
import { getItemSync, setItemSync, removeItemSync } from "../adapters/kv";
|
|
22
8
|
// Keep mmkvStorage export for backwards compat (no-op)
|
|
23
|
-
|
|
9
|
+
export const mmkvStorage = {
|
|
24
10
|
getString: (_key) => null,
|
|
25
11
|
set: (_key, _value) => { },
|
|
26
12
|
delete: (_key) => { },
|
|
27
13
|
};
|
|
28
|
-
|
|
14
|
+
export const zustandStorage = {
|
|
29
15
|
getItem: (name) => {
|
|
30
|
-
const v =
|
|
16
|
+
const v = getItemSync(name);
|
|
31
17
|
return v ? JSON.stringify(v) : null;
|
|
32
18
|
},
|
|
33
19
|
setItem: (name, value) => {
|
|
34
20
|
try {
|
|
35
|
-
|
|
21
|
+
setItemSync(name, JSON.parse(value));
|
|
36
22
|
}
|
|
37
23
|
catch { }
|
|
38
24
|
},
|
|
39
25
|
removeItem: (name) => {
|
|
40
|
-
|
|
26
|
+
removeItemSync(name);
|
|
41
27
|
},
|
|
42
28
|
};
|
|
43
29
|
// Async helpers for code that expects promise-based storage (used by order-number, etc.)
|
|
44
|
-
async function getItemAsync(key) {
|
|
45
|
-
const raw = await
|
|
30
|
+
export async function getItemAsync(key) {
|
|
31
|
+
const raw = await kvGetItem(key);
|
|
46
32
|
if (raw == null)
|
|
47
33
|
return null;
|
|
48
34
|
try {
|
|
@@ -52,9 +38,9 @@ async function getItemAsync(key) {
|
|
|
52
38
|
return null;
|
|
53
39
|
}
|
|
54
40
|
}
|
|
55
|
-
async function setItemAsync(key, value) {
|
|
56
|
-
await
|
|
41
|
+
export async function setItemAsync(key, value) {
|
|
42
|
+
await kvSetItem(key, JSON.stringify(value));
|
|
57
43
|
}
|
|
58
|
-
async function removeItemAsync(key) {
|
|
59
|
-
await
|
|
44
|
+
export async function removeItemAsync(key) {
|
|
45
|
+
await kvRemoveItem(key);
|
|
60
46
|
}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Structured logging for the Sync Engine, commands, events, and transports.
|
|
4
3
|
*
|
|
5
4
|
* Logs are sent to console.debug in debug builds. In production this can be
|
|
6
5
|
* swapped for a crashlytics/analytics sink without changing call sites.
|
|
7
6
|
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.syncLogger = void 0;
|
|
10
7
|
function emit(entry) {
|
|
11
8
|
const { level, namespace, message, data } = entry;
|
|
12
9
|
const tag = `[${namespace}] ${message}`;
|
|
@@ -76,4 +73,4 @@ class SyncLogger {
|
|
|
76
73
|
});
|
|
77
74
|
}
|
|
78
75
|
}
|
|
79
|
-
|
|
76
|
+
export const syncLogger = new SyncLogger();
|
package/dist/utils/uuid.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Client-side UUID generation — plain JS, no expo-crypto.
|
|
4
3
|
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateUUID = generateUUID;
|
|
7
|
-
exports.generateCommandId = generateCommandId;
|
|
8
|
-
exports.generateEventId = generateEventId;
|
|
9
|
-
exports.generateEntityId = generateEntityId;
|
|
10
4
|
function randomHex(bytes) {
|
|
11
5
|
const arr = new Uint8Array(bytes);
|
|
12
6
|
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
@@ -33,15 +27,15 @@ function uuidV4() {
|
|
|
33
27
|
"-" +
|
|
34
28
|
hex.slice(20, 32));
|
|
35
29
|
}
|
|
36
|
-
function generateUUID() {
|
|
30
|
+
export function generateUUID() {
|
|
37
31
|
return uuidV4();
|
|
38
32
|
}
|
|
39
|
-
function generateCommandId() {
|
|
33
|
+
export function generateCommandId() {
|
|
40
34
|
return `cmd_${uuidV4()}`;
|
|
41
35
|
}
|
|
42
|
-
function generateEventId() {
|
|
36
|
+
export function generateEventId() {
|
|
43
37
|
return `evt_${uuidV4()}`;
|
|
44
38
|
}
|
|
45
|
-
function generateEntityId() {
|
|
39
|
+
export function generateEntityId() {
|
|
46
40
|
return uuidV4();
|
|
47
41
|
}
|