@sincpro/mobile 0.1.0
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/README.md +74 -0
- package/dist/adapters/Bluetooth.adapter.d.ts +14 -0
- package/dist/adapters/Bluetooth.adapter.js +100 -0
- package/dist/adapters/Geo.adapter.d.ts +8 -0
- package/dist/adapters/Geo.adapter.js +30 -0
- package/dist/adapters/JsonSerializer.adapter.d.ts +28 -0
- package/dist/adapters/JsonSerializer.adapter.js +47 -0
- package/dist/adapters/Network.adapter.d.ts +4 -0
- package/dist/adapters/Network.adapter.js +13 -0
- package/dist/adapters/ReceiptExporter.adapter.d.ts +19 -0
- package/dist/adapters/ReceiptExporter.adapter.js +142 -0
- package/dist/adapters/repositories/database_table.repository.d.ts +13 -0
- package/dist/adapters/repositories/database_table.repository.js +29 -0
- package/dist/adapters/repositories/domain_event.repository.d.ts +32 -0
- package/dist/adapters/repositories/domain_event.repository.js +147 -0
- package/dist/adapters/repositories/domain_event_dead_letter.repository.d.ts +23 -0
- package/dist/adapters/repositories/domain_event_dead_letter.repository.js +81 -0
- package/dist/adapters/repositories/setting.repository.d.ts +10 -0
- package/dist/adapters/repositories/setting.repository.js +21 -0
- package/dist/adapters/webview.adapter.d.ts +10 -0
- package/dist/adapters/webview.adapter.js +166 -0
- package/dist/domain/connectivity/bluetooth.d.ts +19 -0
- package/dist/domain/connectivity/bluetooth.js +1 -0
- package/dist/domain/connectivity/events.d.ts +17 -0
- package/dist/domain/connectivity/events.js +17 -0
- package/dist/domain/connectivity/geo.d.ts +4 -0
- package/dist/domain/connectivity/geo.js +1 -0
- package/dist/domain/connectivity/index.d.ts +3 -0
- package/dist/domain/connectivity/index.js +3 -0
- package/dist/domain/connectivity/network.d.ts +7 -0
- package/dist/domain/connectivity/network.js +1 -0
- package/dist/domain/database/database.d.ts +16 -0
- package/dist/domain/database/database.js +1 -0
- package/dist/domain/database/index.d.ts +2 -0
- package/dist/domain/database/index.js +2 -0
- package/dist/domain/database/repository.d.ts +19 -0
- package/dist/domain/database/repository.js +1 -0
- package/dist/domain/entity/entity.d.ts +109 -0
- package/dist/domain/entity/entity.js +246 -0
- package/dist/domain/entity/entity_collection.d.ts +396 -0
- package/dist/domain/entity/entity_collection.js +824 -0
- package/dist/domain/entity/index.d.ts +3 -0
- package/dist/domain/entity/index.js +3 -0
- package/dist/domain/entity/value_object.d.ts +12 -0
- package/dist/domain/entity/value_object.js +39 -0
- package/dist/domain/event_sourcing/domain_event.d.ts +58 -0
- package/dist/domain/event_sourcing/domain_event.js +164 -0
- package/dist/domain/event_sourcing/event.d.ts +25 -0
- package/dist/domain/event_sourcing/event.js +25 -0
- package/dist/domain/event_sourcing/event_handler.d.ts +7 -0
- package/dist/domain/event_sourcing/event_handler.js +13 -0
- package/dist/domain/event_sourcing/index.d.ts +2 -0
- package/dist/domain/event_sourcing/index.js +2 -0
- package/dist/domain/events.d.ts +33 -0
- package/dist/domain/events.js +32 -0
- package/dist/domain/icon.d.ts +1 -0
- package/dist/domain/icon.js +1 -0
- package/dist/domain/index.d.ts +9 -0
- package/dist/domain/index.js +9 -0
- package/dist/domain/print/driver_registry.d.ts +4 -0
- package/dist/domain/print/driver_registry.js +29 -0
- package/dist/domain/print/events.d.ts +13 -0
- package/dist/domain/print/events.js +13 -0
- package/dist/domain/print/index.d.ts +2 -0
- package/dist/domain/print/index.js +1 -0
- package/dist/domain/print/printer.d.ts +35 -0
- package/dist/domain/print/printer.js +1 -0
- package/dist/domain/receipt.d.ts +31 -0
- package/dist/domain/receipt.js +1 -0
- package/dist/domain/repositories.d.ts +6 -0
- package/dist/domain/repositories.js +7 -0
- package/dist/domain/settings.d.ts +7 -0
- package/dist/domain/settings.js +1 -0
- package/dist/domain/webview/events.d.ts +11 -0
- package/dist/domain/webview/events.js +11 -0
- package/dist/domain/webview/index.d.ts +1 -0
- package/dist/domain/webview/index.js +1 -0
- package/dist/domain/webview/webview.d.ts +57 -0
- package/dist/domain/webview/webview.js +9 -0
- package/dist/entrypoints/cron/Cron.d.ts +13 -0
- package/dist/entrypoints/cron/Cron.js +57 -0
- package/dist/entrypoints/cron/checkNetworkStatus.cron.d.ts +3 -0
- package/dist/entrypoints/cron/checkNetworkStatus.cron.js +10 -0
- package/dist/entrypoints/db/index.d.ts +2 -0
- package/dist/entrypoints/db/index.js +2 -0
- package/dist/entrypoints/db/migrations.d.ts +10 -0
- package/dist/entrypoints/db/migrations.js +115 -0
- package/dist/entrypoints/db/repositories.d.ts +8 -0
- package/dist/entrypoints/db/repositories.js +34 -0
- package/dist/entrypoints/queue/QueueProcessor.d.ts +12 -0
- package/dist/entrypoints/queue/QueueProcessor.js +75 -0
- package/dist/entrypoints/queue/activateDomain.subscriber.d.ts +7 -0
- package/dist/entrypoints/queue/activateDomain.subscriber.js +15 -0
- package/dist/entrypoints/queue/newAppSettings.handler.d.ts +7 -0
- package/dist/entrypoints/queue/newAppSettings.handler.js +17 -0
- package/dist/entrypoints/queue/printImage.subscriber.d.ts +7 -0
- package/dist/entrypoints/queue/printImage.subscriber.js +14 -0
- package/dist/entrypoints/queue/processWebViewMessage.subscriber.d.ts +7 -0
- package/dist/entrypoints/queue/processWebViewMessage.subscriber.js +23 -0
- package/dist/entrypoints/ui/AppShell.d.ts +15 -0
- package/dist/entrypoints/ui/AppShell.js +58 -0
- package/dist/entrypoints/ui/common_provider.d.ts +35 -0
- package/dist/entrypoints/ui/common_provider.js +244 -0
- package/dist/entrypoints/ui/domain_switcher.d.ts +19 -0
- package/dist/entrypoints/ui/domain_switcher.js +22 -0
- package/dist/entrypoints/ui/theme.d.ts +15 -0
- package/dist/entrypoints/ui/theme.js +16 -0
- package/dist/exceptions.d.ts +22 -0
- package/dist/exceptions.js +60 -0
- package/dist/framework/base_module.d.ts +14 -0
- package/dist/framework/base_module.js +40 -0
- package/dist/framework/createApp.d.ts +6 -0
- package/dist/framework/createApp.js +9 -0
- package/dist/framework/domain_module.d.ts +13 -0
- package/dist/framework/domain_module.js +18 -0
- package/dist/framework/kernel.d.ts +18 -0
- package/dist/framework/kernel.js +60 -0
- package/dist/framework/orchestrator.d.ts +29 -0
- package/dist/framework/orchestrator.js +118 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +11 -0
- package/dist/infrastructure/database/connector.d.ts +13 -0
- package/dist/infrastructure/database/connector.js +165 -0
- package/dist/infrastructure/database/index.d.ts +2 -0
- package/dist/infrastructure/database/index.js +2 -0
- package/dist/infrastructure/database/mapped.d.ts +128 -0
- package/dist/infrastructure/database/mapped.js +174 -0
- package/dist/infrastructure/database/utils.d.ts +10 -0
- package/dist/infrastructure/database/utils.js +35 -0
- package/dist/infrastructure/logger.d.ts +45 -0
- package/dist/infrastructure/logger.js +125 -0
- package/dist/infrastructure/ui/ToastHost.d.ts +1 -0
- package/dist/infrastructure/ui/ToastHost.js +19 -0
- package/dist/infrastructure/ui/UIEventBus.d.ts +12 -0
- package/dist/infrastructure/ui/UIEventBus.js +65 -0
- package/dist/infrastructure/ui/errorHandler.d.ts +1 -0
- package/dist/infrastructure/ui/errorHandler.js +20 -0
- package/dist/infrastructure/ui/events.d.ts +1 -0
- package/dist/infrastructure/ui/events.js +1 -0
- package/dist/infrastructure/workers/CronWorker.d.ts +42 -0
- package/dist/infrastructure/workers/CronWorker.js +143 -0
- package/dist/infrastructure/workers/EventBus.d.ts +67 -0
- package/dist/infrastructure/workers/EventBus.js +279 -0
- package/dist/infrastructure/workers/index.d.ts +2 -0
- package/dist/infrastructure/workers/index.js +2 -0
- package/dist/services/bluetooth.service.d.ts +14 -0
- package/dist/services/bluetooth.service.js +72 -0
- package/dist/services/database_table.service.d.ts +8 -0
- package/dist/services/database_table.service.js +19 -0
- package/dist/services/dead_letter_queue.service.d.ts +38 -0
- package/dist/services/dead_letter_queue.service.js +99 -0
- package/dist/services/event.service.d.ts +7 -0
- package/dist/services/event.service.js +24 -0
- package/dist/services/network.service.d.ts +7 -0
- package/dist/services/network.service.js +43 -0
- package/dist/services/printer.service.d.ts +25 -0
- package/dist/services/printer.service.js +220 -0
- package/dist/services/webview.service.d.ts +17 -0
- package/dist/services/webview.service.js +59 -0
- package/dist/tools/utils/Initials.d.ts +1 -0
- package/dist/tools/utils/Initials.js +12 -0
- package/dist/tools/utils/collections.d.ts +120 -0
- package/dist/tools/utils/collections.js +158 -0
- package/dist/tools/utils/date.d.ts +70 -0
- package/dist/tools/utils/date.js +126 -0
- package/dist/tools/utils/maps.d.ts +4 -0
- package/dist/tools/utils/maps.js +20 -0
- package/dist/tools/utils/monetary.d.ts +3 -0
- package/dist/tools/utils/monetary.js +31 -0
- package/dist/tools/utils/quantity.d.ts +11 -0
- package/dist/tools/utils/quantity.js +44 -0
- package/dist/tools/utils/searchTools.d.ts +39 -0
- package/dist/tools/utils/searchTools.js +56 -0
- package/dist/tools/utils/serializer.d.ts +2 -0
- package/dist/tools/utils/serializer.js +44 -0
- package/dist/ui/components/atoms/DebugBanner.d.ts +2 -0
- package/dist/ui/components/atoms/DebugBanner.js +15 -0
- package/dist/ui/components/atoms/index.d.ts +1 -0
- package/dist/ui/components/atoms/index.js +1 -0
- package/dist/ui/components/molecules/BluetoothDeviceSelectorModal.d.ts +8 -0
- package/dist/ui/components/molecules/BluetoothDeviceSelectorModal.js +61 -0
- package/dist/ui/components/molecules/DeadLetterErrorBlock.d.ts +8 -0
- package/dist/ui/components/molecules/DeadLetterErrorBlock.js +14 -0
- package/dist/ui/components/molecules/EventTimelineItem.d.ts +7 -0
- package/dist/ui/components/molecules/EventTimelineItem.js +65 -0
- package/dist/ui/components/molecules/ProcessToast.d.ts +5 -0
- package/dist/ui/components/molecules/ProcessToast.js +51 -0
- package/dist/ui/components/molecules/ProcessToastProvider.d.ts +4 -0
- package/dist/ui/components/molecules/ProcessToastProvider.js +5 -0
- package/dist/ui/components/molecules/index.d.ts +5 -0
- package/dist/ui/components/molecules/index.js +5 -0
- package/dist/ui/components/organisms/BluetoothPrinterSelector.d.ts +7 -0
- package/dist/ui/components/organisms/BluetoothPrinterSelector.js +92 -0
- package/dist/ui/components/organisms/DatabaseInfoRow.d.ts +11 -0
- package/dist/ui/components/organisms/DatabaseInfoRow.js +8 -0
- package/dist/ui/components/organisms/DeadLetterQueueRow.d.ts +7 -0
- package/dist/ui/components/organisms/DeadLetterQueueRow.js +72 -0
- package/dist/ui/components/organisms/EventRow.d.ts +7 -0
- package/dist/ui/components/organisms/EventRow.js +90 -0
- package/dist/ui/components/organisms/InjectableWebView.d.ts +35 -0
- package/dist/ui/components/organisms/InjectableWebView.js +169 -0
- package/dist/ui/components/organisms/Receipt.d.ts +11 -0
- package/dist/ui/components/organisms/Receipt.js +207 -0
- package/dist/ui/components/organisms/TableInfoInfoRow.d.ts +9 -0
- package/dist/ui/components/organisms/TableInfoInfoRow.js +19 -0
- package/dist/ui/components/organisms/index.d.ts +7 -0
- package/dist/ui/components/organisms/index.js +7 -0
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.js +4 -0
- package/dist/ui/layouts/router_layouts.d.ts +17 -0
- package/dist/ui/layouts/router_layouts.js +20 -0
- package/dist/ui/screens/database/database.context.d.ts +32 -0
- package/dist/ui/screens/database/database.context.js +158 -0
- package/dist/ui/screens/database/database.json_detail.d.ts +2 -0
- package/dist/ui/screens/database/database.json_detail.js +19 -0
- package/dist/ui/screens/database/database.list.d.ts +1 -0
- package/dist/ui/screens/database/database.list.js +41 -0
- package/dist/ui/screens/database/database.table_rows.d.ts +2 -0
- package/dist/ui/screens/database/database.table_rows.js +10 -0
- package/dist/ui/screens/dead_letter_queue/dead_letter_queue.context.d.ts +34 -0
- package/dist/ui/screens/dead_letter_queue/dead_letter_queue.context.js +166 -0
- package/dist/ui/screens/dead_letter_queue/dead_letter_queue.list.d.ts +2 -0
- package/dist/ui/screens/dead_letter_queue/dead_letter_queue.list.js +24 -0
- package/dist/ui/screens/events/events.context.d.ts +25 -0
- package/dist/ui/screens/events/events.context.js +113 -0
- package/dist/ui/screens/events/events.list.d.ts +1 -0
- package/dist/ui/screens/events/events.list.js +26 -0
- package/dist/ui/screens/events/index.d.ts +1 -0
- package/dist/ui/screens/events/index.js +1 -0
- package/dist/ui/screens/index.d.ts +3 -0
- package/dist/ui/screens/index.js +3 -0
- package/package.json +125 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "nativewind/jsx-runtime";
|
|
2
|
+
import React, { useMemo } from "react";
|
|
3
|
+
import { Platform, ScrollView, Text, View } from "react-native";
|
|
4
|
+
const isPrimitive = (value) => value == null || ["string", "number", "boolean"].includes(typeof value);
|
|
5
|
+
const isPlainObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6
|
+
const isTableData = (array) => array.length > 0 && array.every(isPlainObject);
|
|
7
|
+
const flattenToStrings = (value) => {
|
|
8
|
+
const flatten = (item) => {
|
|
9
|
+
if (Array.isArray(item))
|
|
10
|
+
return item.flatMap(flatten);
|
|
11
|
+
return [String(item ?? "")];
|
|
12
|
+
};
|
|
13
|
+
return isPrimitive(value) ? [String(value ?? "")] : flatten(value);
|
|
14
|
+
};
|
|
15
|
+
const extractAllKeys = (objects) => {
|
|
16
|
+
const keySet = new Set();
|
|
17
|
+
objects.forEach((obj) => Object.keys(obj).forEach((key) => keySet.add(key)));
|
|
18
|
+
return Array.from(keySet);
|
|
19
|
+
};
|
|
20
|
+
const getDisplayKeys = (baseKeys, order, strictOrder = false) => {
|
|
21
|
+
if (!order?.length)
|
|
22
|
+
return baseKeys;
|
|
23
|
+
if (strictOrder)
|
|
24
|
+
return order;
|
|
25
|
+
return [...order, ...baseKeys.filter((key) => !order.includes(key))];
|
|
26
|
+
};
|
|
27
|
+
const safeStringify = (value) => {
|
|
28
|
+
try {
|
|
29
|
+
return isPrimitive(value) ? String(value) : JSON.stringify(value);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return "[Complex Object]";
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const arrayToTableFormat = (array, columnName = "Tipo") => {
|
|
36
|
+
return array.map((item) => ({
|
|
37
|
+
[columnName]: safeStringify(item),
|
|
38
|
+
}));
|
|
39
|
+
};
|
|
40
|
+
const calculateIntelligentColumnWidths = (rows, columns) => {
|
|
41
|
+
if (columns.length === 0) {
|
|
42
|
+
return {};
|
|
43
|
+
}
|
|
44
|
+
const columnMetrics = columns.map((column) => {
|
|
45
|
+
const headerLength = column.length;
|
|
46
|
+
const maxContentLength = Math.max(...rows.map((row) => String(row[column] || "").length), 0);
|
|
47
|
+
const avgContentLength = rows.length > 0
|
|
48
|
+
? rows.reduce((sum, row) => sum + String(row[column] || "").length, 0) / rows.length
|
|
49
|
+
: 0;
|
|
50
|
+
const isNumeric = rows.every((row) => row[column] == null || !isNaN(Number(String(row[column]).replace(/[,\s]/g, ""))));
|
|
51
|
+
const isShortNumeric = isNumeric && maxContentLength <= 10;
|
|
52
|
+
return {
|
|
53
|
+
column,
|
|
54
|
+
headerLength,
|
|
55
|
+
maxContentLength,
|
|
56
|
+
avgContentLength,
|
|
57
|
+
isNumeric,
|
|
58
|
+
isShortNumeric,
|
|
59
|
+
effectiveLength: Math.max(headerLength, maxContentLength),
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
const weightedMetrics = columnMetrics.map((metric) => {
|
|
63
|
+
let weight = metric.effectiveLength;
|
|
64
|
+
if (metric.isShortNumeric) {
|
|
65
|
+
weight *= 0.7;
|
|
66
|
+
}
|
|
67
|
+
else if (metric.isNumeric) {
|
|
68
|
+
weight *= 0.8;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
weight *= 1.2;
|
|
72
|
+
}
|
|
73
|
+
if (metric.maxContentLength > 20) {
|
|
74
|
+
weight *= 1.3;
|
|
75
|
+
}
|
|
76
|
+
return { ...metric, weight };
|
|
77
|
+
});
|
|
78
|
+
const totalWeight = weightedMetrics.reduce((sum, metric) => sum + metric.weight, 0);
|
|
79
|
+
const widths = {};
|
|
80
|
+
weightedMetrics.forEach((metric) => {
|
|
81
|
+
const basePercentage = (metric.weight / totalWeight) * 100;
|
|
82
|
+
let finalPercentage = basePercentage;
|
|
83
|
+
if (metric.isShortNumeric) {
|
|
84
|
+
finalPercentage = Math.max(finalPercentage, 12);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
finalPercentage = Math.max(finalPercentage, 15);
|
|
88
|
+
}
|
|
89
|
+
finalPercentage = Math.min(finalPercentage, 60);
|
|
90
|
+
widths[metric.column] = finalPercentage;
|
|
91
|
+
});
|
|
92
|
+
const currentTotal = Object.values(widths).reduce((sum, width) => sum + width, 0);
|
|
93
|
+
const normalizationFactor = 100 / currentTotal;
|
|
94
|
+
Object.keys(widths).forEach((column) => {
|
|
95
|
+
widths[column] = Math.round(widths[column] * normalizationFactor);
|
|
96
|
+
});
|
|
97
|
+
return widths;
|
|
98
|
+
};
|
|
99
|
+
function ValueRenderer({ value, formatter, emptyPlaceholder, centered = false, renderAs, }) {
|
|
100
|
+
if (formatter) {
|
|
101
|
+
const formatted = formatter(value);
|
|
102
|
+
return React.isValidElement(formatted) ? (formatted) : (_jsx(Text, { className: centered ? "text-center" : "", children: String(formatted) }));
|
|
103
|
+
}
|
|
104
|
+
if (Array.isArray(value)) {
|
|
105
|
+
return (_jsx(ArrayRenderer, { centered: centered, emptyPlaceholder: emptyPlaceholder, renderAs: renderAs, value: value }));
|
|
106
|
+
}
|
|
107
|
+
if (renderAs === "text") {
|
|
108
|
+
const displayValue = value == null ? emptyPlaceholder : safeStringify(value);
|
|
109
|
+
return _jsx(Text, { className: centered ? "text-center" : "", children: displayValue });
|
|
110
|
+
}
|
|
111
|
+
const displayValue = value == null ? emptyPlaceholder : safeStringify(value);
|
|
112
|
+
return _jsx(Text, { className: centered ? "text-center" : "", children: displayValue });
|
|
113
|
+
}
|
|
114
|
+
function ArrayRenderer({ value, emptyPlaceholder, centered = false, renderAs, }) {
|
|
115
|
+
if (value.length === 0) {
|
|
116
|
+
return _jsx(Text, { className: centered ? "text-center" : "", children: emptyPlaceholder });
|
|
117
|
+
}
|
|
118
|
+
if (renderAs === "table") {
|
|
119
|
+
const tableData = isTableData(value) ? value : arrayToTableFormat(value, "Tipo");
|
|
120
|
+
return _jsx(TableRenderer, { emptyPlaceholder: emptyPlaceholder, rows: tableData });
|
|
121
|
+
}
|
|
122
|
+
if (renderAs === "list") {
|
|
123
|
+
const flatContent = flattenToStrings(value).join(", ") || emptyPlaceholder;
|
|
124
|
+
return _jsx(Text, { className: centered ? "text-center" : "", children: flatContent });
|
|
125
|
+
}
|
|
126
|
+
if (renderAs === "text") {
|
|
127
|
+
const textContent = flattenToStrings(value).join(" ") || emptyPlaceholder;
|
|
128
|
+
return _jsx(Text, { className: centered ? "text-center" : "", children: textContent });
|
|
129
|
+
}
|
|
130
|
+
if (isTableData(value)) {
|
|
131
|
+
return _jsx(TableRenderer, { emptyPlaceholder: emptyPlaceholder, rows: value });
|
|
132
|
+
}
|
|
133
|
+
const flatContent = flattenToStrings(value).join(", ") || emptyPlaceholder;
|
|
134
|
+
return _jsx(Text, { className: centered ? "text-center" : "", children: flatContent });
|
|
135
|
+
}
|
|
136
|
+
function TableRenderer({ rows, emptyPlaceholder }) {
|
|
137
|
+
const columns = useMemo(() => extractAllKeys(rows), [rows]);
|
|
138
|
+
const columnWidths = useMemo(() => calculateIntelligentColumnWidths(rows, columns), [rows, columns]);
|
|
139
|
+
return (_jsxs(View, { className: "mt-0.5", children: [_jsx(TableHeader, { columns: columns, columnWidths: columnWidths }), rows.map((row, index) => (_jsx(TableRow, { columns: columns, columnWidths: columnWidths, emptyPlaceholder: emptyPlaceholder, row: row }, index)))] }));
|
|
140
|
+
}
|
|
141
|
+
function TableHeader({ columns, columnWidths }) {
|
|
142
|
+
return (_jsx(View, { className: "flex-row border-t border-b-2 border-black py-0.5", children: columns.map((column) => (_jsx(Text, { className: "flex-1 px-1 py-0.5 font-bold text-xs", numberOfLines: 1, style: { width: `${columnWidths[column]}%` }, children: column }, column))) }));
|
|
143
|
+
}
|
|
144
|
+
function TableRow({ row, columns, emptyPlaceholder, columnWidths }) {
|
|
145
|
+
return (_jsx(View, { className: "flex-row border-b border-black py-0.5", children: columns.map((column) => {
|
|
146
|
+
const cellValue = row[column] == null ? emptyPlaceholder : safeStringify(row[column]);
|
|
147
|
+
return (_jsx(Text, { className: "flex-1 px-1 py-0.5", style: { width: `${columnWidths[column]}%` }, children: cellValue }, column));
|
|
148
|
+
}) }));
|
|
149
|
+
}
|
|
150
|
+
function ReceiptField({ fieldKey, value, label, formatter, emptyPlaceholder, }) {
|
|
151
|
+
const labelConfig = typeof label === "object" && label !== null && "label" in label ? label : null;
|
|
152
|
+
const displayLabel = labelConfig?.label ?? label;
|
|
153
|
+
const alignOverride = labelConfig?.align;
|
|
154
|
+
const renderAs = labelConfig?.renderAs;
|
|
155
|
+
if (displayLabel === false) {
|
|
156
|
+
const contentClass = alignOverride === "left"
|
|
157
|
+
? "items-start my-0.5"
|
|
158
|
+
: alignOverride === "right"
|
|
159
|
+
? "items-end my-0.5"
|
|
160
|
+
: "items-center my-0.5";
|
|
161
|
+
return (_jsx(View, { className: contentClass, children: _jsx(ValueRenderer, { centered: alignOverride ? alignOverride === "center" : true, emptyPlaceholder: emptyPlaceholder, formatter: formatter, renderAs: renderAs, value: value }) }));
|
|
162
|
+
}
|
|
163
|
+
const finalLabel = typeof displayLabel === "string" ? displayLabel : fieldKey;
|
|
164
|
+
const isArrayValue = Array.isArray(value);
|
|
165
|
+
const shouldRenderAsTable = renderAs === "table" ||
|
|
166
|
+
(renderAs !== "list" && renderAs !== "text" && isArrayValue && isTableData(value));
|
|
167
|
+
if (shouldRenderAsTable) {
|
|
168
|
+
return (_jsxs(View, { className: "mb-2", children: [_jsxs(Text, { className: "font-bold mb-0.5", children: [finalLabel, ":"] }), _jsx(ValueRenderer, { emptyPlaceholder: emptyPlaceholder, formatter: formatter, renderAs: renderAs, value: value })] }));
|
|
169
|
+
}
|
|
170
|
+
if (fieldKey === "numericKey" && typeof value === "string" && value.length > 0) {
|
|
171
|
+
const rawGroups = value.trim().split(/\s+/);
|
|
172
|
+
const lines = [];
|
|
173
|
+
let current = "";
|
|
174
|
+
for (const g of rawGroups) {
|
|
175
|
+
const candidate = current ? current + " " + g : g;
|
|
176
|
+
if (candidate.length > 25 && current) {
|
|
177
|
+
lines.push(current);
|
|
178
|
+
current = g;
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
current = candidate;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (current)
|
|
185
|
+
lines.push(current);
|
|
186
|
+
return (_jsxs(View, { className: "my-1.5", children: [_jsxs(Text, { className: "font-bold", children: [finalLabel, ":"] }), _jsx(View, { className: "mt-0.5 px-1.5 py-1 bg-bg-hover rounded items-center gap-0.5", children: lines.map((ln, idx) => (_jsx(Text, { adjustsFontSizeToFit: true, numberOfLines: 1, style: {
|
|
187
|
+
fontFamily: Platform.select({
|
|
188
|
+
ios: "Menlo",
|
|
189
|
+
android: "monospace",
|
|
190
|
+
default: undefined,
|
|
191
|
+
}),
|
|
192
|
+
letterSpacing: 1,
|
|
193
|
+
fontSize: 11,
|
|
194
|
+
}, children: ln }, idx))) })] }));
|
|
195
|
+
}
|
|
196
|
+
return (_jsxs(View, { className: "flex-row justify-between items-start py-0.5", children: [_jsxs(Text, { className: "font-bold", children: [finalLabel, ":"] }), _jsx(View, { className: "items-end", children: _jsx(ValueRenderer, { emptyPlaceholder: emptyPlaceholder, formatter: formatter, renderAs: renderAs, value: value }) })] }));
|
|
197
|
+
}
|
|
198
|
+
function Receipt({ data, labels = {}, order, strictOrder = false, formatters = {}, emptyPlaceholder = "---", }) {
|
|
199
|
+
const displayKeys = useMemo(() => getDisplayKeys(Object.keys(data), order, strictOrder), [data, order, strictOrder]);
|
|
200
|
+
return (_jsx(ScrollView, { contentContainerClassName: "p-4 gap-0.5", children: displayKeys.map((key) => {
|
|
201
|
+
if (labels[key] === "separator") {
|
|
202
|
+
return _jsx(View, { className: "h-[1px] bg-border-divider my-1" }, key);
|
|
203
|
+
}
|
|
204
|
+
return (_jsx(ReceiptField, { emptyPlaceholder: emptyPlaceholder, fieldKey: key, formatter: formatters[key], label: labels[key], value: data[key] }, key));
|
|
205
|
+
}) }));
|
|
206
|
+
}
|
|
207
|
+
export default Receipt;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface TableRowData {
|
|
2
|
+
data: unknown;
|
|
3
|
+
}
|
|
4
|
+
interface TableListItemProps {
|
|
5
|
+
item: TableRowData;
|
|
6
|
+
onPress?: () => void;
|
|
7
|
+
}
|
|
8
|
+
declare function TableInfoRow({ item, onPress }: TableListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default TableInfoRow;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "nativewind/jsx-runtime";
|
|
2
|
+
import { safeJsonParse, safeJsonStringify } from "../../../tools/utils/serializer";
|
|
3
|
+
import { Typography } from "@sincpro/mobile-ui/Typography";
|
|
4
|
+
import { TouchableOpacity, View } from "react-native";
|
|
5
|
+
function TableInfoRow({ item, onPress }) {
|
|
6
|
+
const parsedData = safeJsonParse(typeof item.data === "string" ? item.data : safeJsonStringify(item.data)) || {
|
|
7
|
+
raw: item.data,
|
|
8
|
+
};
|
|
9
|
+
let messageId = "";
|
|
10
|
+
if (parsedData && parsedData.remote_id) {
|
|
11
|
+
messageId = `(${parsedData.remote_id}) `;
|
|
12
|
+
}
|
|
13
|
+
if (parsedData.uuid) {
|
|
14
|
+
messageId += `[${parsedData.uuid})]`;
|
|
15
|
+
}
|
|
16
|
+
const jsonString = safeJsonStringify(parsedData);
|
|
17
|
+
return (_jsx(TouchableOpacity, { activeOpacity: 0.7, className: "bg-white p-4 rounded-xl my-2 shadow-sm", onPress: onPress, children: _jsxs(View, { children: [_jsx(Typography.Text, { className: "mb-2", variant: "caption", children: parsedData.name || "Sin Nombre" }), _jsx(Typography.Text, { numberOfLines: 1, semibold: true, variant: "body", children: messageId || "Sin Identificador" }), parsedData.status && (_jsxs(Typography.Text, { variant: "label", children: ["Estado: ", parsedData.status] })), _jsx(Typography.Text, { className: "text-gray-500", ellipsizeMode: "tail", numberOfLines: 2, variant: "bodySmall", children: jsonString })] }) }));
|
|
18
|
+
}
|
|
19
|
+
export default TableInfoRow;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { BluetoothPrinterSelector } from "./BluetoothPrinterSelector";
|
|
2
|
+
export { default as DatabaseInfoRow } from "./DatabaseInfoRow";
|
|
3
|
+
export { default as DeadLetterQueueRow } from "./DeadLetterQueueRow";
|
|
4
|
+
export { default as EventRow } from "./EventRow";
|
|
5
|
+
export { InjectableWebView } from "./InjectableWebView";
|
|
6
|
+
export { default as Receipt } from "./Receipt";
|
|
7
|
+
export { default as TableInfoRow } from "./TableInfoInfoRow";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { BluetoothPrinterSelector } from "./BluetoothPrinterSelector";
|
|
2
|
+
export { default as DatabaseInfoRow } from "./DatabaseInfoRow";
|
|
3
|
+
export { default as DeadLetterQueueRow } from "./DeadLetterQueueRow";
|
|
4
|
+
export { default as EventRow } from "./EventRow";
|
|
5
|
+
export { InjectableWebView } from "./InjectableWebView";
|
|
6
|
+
export { default as Receipt } from "./Receipt";
|
|
7
|
+
export { default as TableInfoRow } from "./TableInfoInfoRow";
|
package/dist/ui/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import UITabNavigatorLayout from "@sincpro/mobile-ui/layouts/TabNavigatorLayout";
|
|
2
|
+
import type { ComponentProps, ReactElement } from "react";
|
|
3
|
+
type UITabProps = ComponentProps<typeof UITabNavigatorLayout>;
|
|
4
|
+
/**
|
|
5
|
+
* Layouts conectados a react-router. El design system (@sincpro/mobile-ui) trae
|
|
6
|
+
* las versiones presentacionales (sin router); aquí el core —que sí posee el
|
|
7
|
+
* router— les inyecta location/navigate/Outlet para usarse como layout routes.
|
|
8
|
+
*/
|
|
9
|
+
declare function TabNavigatorLayout(props: Omit<UITabProps, "content" | "currentPath" | "onTabPress">): ReactElement;
|
|
10
|
+
declare namespace TabNavigatorLayout {
|
|
11
|
+
var Tabs: ({ children: tabsChildren }: {
|
|
12
|
+
children?: import("react").ReactNode;
|
|
13
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
var Tab: (_props: import("@sincpro/mobile-ui/layouts/TabNavigatorLayout").TabProps) => null;
|
|
15
|
+
}
|
|
16
|
+
declare function PlainLayout(): ReactElement;
|
|
17
|
+
export { PlainLayout, TabNavigatorLayout };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import UIPlainLayout from "@sincpro/mobile-ui/layouts/PlainLayout";
|
|
3
|
+
import UITabNavigatorLayout from "@sincpro/mobile-ui/layouts/TabNavigatorLayout";
|
|
4
|
+
import { Outlet, useLocation, useNavigate } from "react-router-native";
|
|
5
|
+
/**
|
|
6
|
+
* Layouts conectados a react-router. El design system (@sincpro/mobile-ui) trae
|
|
7
|
+
* las versiones presentacionales (sin router); aquí el core —que sí posee el
|
|
8
|
+
* router— les inyecta location/navigate/Outlet para usarse como layout routes.
|
|
9
|
+
*/
|
|
10
|
+
function TabNavigatorLayout(props) {
|
|
11
|
+
const location = useLocation();
|
|
12
|
+
const navigate = useNavigate();
|
|
13
|
+
return (_jsx(UITabNavigatorLayout, { ...props, content: _jsx(Outlet, {}), currentPath: location.pathname, onTabPress: (path) => navigate(path) }));
|
|
14
|
+
}
|
|
15
|
+
TabNavigatorLayout.Tabs = UITabNavigatorLayout.Tabs;
|
|
16
|
+
TabNavigatorLayout.Tab = UITabNavigatorLayout.Tab;
|
|
17
|
+
function PlainLayout() {
|
|
18
|
+
return (_jsx(UIPlainLayout, { children: _jsx(Outlet, {}) }));
|
|
19
|
+
}
|
|
20
|
+
export { PlainLayout, TabNavigatorLayout };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export declare enum EDatabaseView {
|
|
3
|
+
TABLES_LIST = "TABLES_LIST",
|
|
4
|
+
TABLE_ROWS = "TABLE_ROWS",
|
|
5
|
+
JSON_DETAIL = "JSON_DETAIL"
|
|
6
|
+
}
|
|
7
|
+
interface IDatabaseContext {
|
|
8
|
+
currentView: EDatabaseView;
|
|
9
|
+
tables: any[];
|
|
10
|
+
data: any[];
|
|
11
|
+
filteredData: any[];
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
selectedTable: string;
|
|
14
|
+
selectedRowJson: string;
|
|
15
|
+
searchQuery: string;
|
|
16
|
+
currentRowIndex: number;
|
|
17
|
+
hasNextRow: boolean;
|
|
18
|
+
hasPreviousRow: boolean;
|
|
19
|
+
loadTables: () => Promise<void>;
|
|
20
|
+
selectTable: (tableName: string) => Promise<void>;
|
|
21
|
+
goBackFromRows: () => void;
|
|
22
|
+
selectRowJson: (json: string, index: number) => void;
|
|
23
|
+
goBackFromJson: () => void;
|
|
24
|
+
setSearchQuery: (query: string) => void;
|
|
25
|
+
goToNextRow: () => void;
|
|
26
|
+
goToPreviousRow: () => void;
|
|
27
|
+
}
|
|
28
|
+
export declare function DatabaseProvider({ children }: {
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare function useDatabase(): IDatabaseContext;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import { databaseTablesUseCase } from "../../../services/database_table.service";
|
|
3
|
+
import { safeJsonParse, safeJsonStringify } from "../../../tools/utils/serializer";
|
|
4
|
+
import { createContext, useCallback, useContext, useEffect, useState, } from "react";
|
|
5
|
+
export var EDatabaseView;
|
|
6
|
+
(function (EDatabaseView) {
|
|
7
|
+
EDatabaseView["TABLES_LIST"] = "TABLES_LIST";
|
|
8
|
+
EDatabaseView["TABLE_ROWS"] = "TABLE_ROWS";
|
|
9
|
+
EDatabaseView["JSON_DETAIL"] = "JSON_DETAIL";
|
|
10
|
+
})(EDatabaseView || (EDatabaseView = {}));
|
|
11
|
+
const DatabaseContext = createContext(null);
|
|
12
|
+
export function DatabaseProvider({ children }) {
|
|
13
|
+
const [currentView, setCurrentView] = useState(EDatabaseView.TABLES_LIST);
|
|
14
|
+
const [tables, setTables] = useState([]);
|
|
15
|
+
const [data, setData] = useState([]);
|
|
16
|
+
const [filteredData, setFilteredData] = useState([]);
|
|
17
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
18
|
+
const [selectedTable, setSelectedTable] = useState("");
|
|
19
|
+
const [selectedRowJson, setSelectedRowJson] = useState("");
|
|
20
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
21
|
+
const [currentRowIndex, setCurrentRowIndex] = useState(0);
|
|
22
|
+
const [previousSearchQuery, setPreviousSearchQuery] = useState("");
|
|
23
|
+
const [isTransitioning, setIsTransitioning] = useState(false);
|
|
24
|
+
const filterData = useCallback(() => {
|
|
25
|
+
if (!searchQuery.trim()) {
|
|
26
|
+
setFilteredData(data);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const query = searchQuery.toLowerCase().trim();
|
|
30
|
+
const filtered = data.filter((row) => {
|
|
31
|
+
const parsedData = safeJsonParse(typeof row === "string" ? row : JSON.stringify(row));
|
|
32
|
+
if (!parsedData)
|
|
33
|
+
return false;
|
|
34
|
+
const remoteId = parsedData.remote_id?.toString().toLowerCase() || "";
|
|
35
|
+
const uuid = parsedData.uuid?.toLowerCase() || "";
|
|
36
|
+
const name = parsedData.name?.toLowerCase() || "";
|
|
37
|
+
return remoteId.includes(query) || uuid.includes(query) || name.includes(query);
|
|
38
|
+
});
|
|
39
|
+
setFilteredData(filtered);
|
|
40
|
+
}, [data, searchQuery]);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
filterData();
|
|
43
|
+
}, [filterData]);
|
|
44
|
+
const loadTables = useCallback(async () => {
|
|
45
|
+
setIsLoading(true);
|
|
46
|
+
try {
|
|
47
|
+
const result = await databaseTablesUseCase.getAllTables();
|
|
48
|
+
setTables(result);
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
setIsLoading(false);
|
|
52
|
+
}
|
|
53
|
+
}, []);
|
|
54
|
+
const loadTableData = useCallback(async (tableName) => {
|
|
55
|
+
setIsLoading(true);
|
|
56
|
+
try {
|
|
57
|
+
const dataTable = await databaseTablesUseCase.getTableData(tableName);
|
|
58
|
+
setData(dataTable);
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
setIsLoading(false);
|
|
62
|
+
}
|
|
63
|
+
}, []);
|
|
64
|
+
const selectTable = useCallback(async (tableName) => {
|
|
65
|
+
setSelectedTable(tableName);
|
|
66
|
+
await loadTableData(tableName);
|
|
67
|
+
setCurrentView(EDatabaseView.TABLE_ROWS);
|
|
68
|
+
}, [loadTableData]);
|
|
69
|
+
const goBackFromRows = useCallback(() => {
|
|
70
|
+
setSelectedTable("");
|
|
71
|
+
setData([]);
|
|
72
|
+
setCurrentRowIndex(0);
|
|
73
|
+
setSearchQuery("");
|
|
74
|
+
setPreviousSearchQuery("");
|
|
75
|
+
setCurrentView(EDatabaseView.TABLES_LIST);
|
|
76
|
+
}, []);
|
|
77
|
+
const selectRowJson = useCallback((json, index) => {
|
|
78
|
+
if (isTransitioning) {
|
|
79
|
+
console.log("[Database] Ignoring rapid click - transition in progress");
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
setIsTransitioning(true);
|
|
83
|
+
setSelectedRowJson(json);
|
|
84
|
+
setCurrentRowIndex(index);
|
|
85
|
+
setCurrentView(EDatabaseView.JSON_DETAIL);
|
|
86
|
+
setTimeout(() => {
|
|
87
|
+
setIsTransitioning(false);
|
|
88
|
+
}, 300);
|
|
89
|
+
}, [isTransitioning]);
|
|
90
|
+
const goBackFromJson = useCallback(() => {
|
|
91
|
+
setSelectedRowJson("");
|
|
92
|
+
setCurrentView(EDatabaseView.TABLE_ROWS);
|
|
93
|
+
}, []);
|
|
94
|
+
const goToNextRow = useCallback(() => {
|
|
95
|
+
if (isTransitioning)
|
|
96
|
+
return; // Protección contra clics rápidos
|
|
97
|
+
if (currentRowIndex < filteredData.length - 1) {
|
|
98
|
+
setIsTransitioning(true);
|
|
99
|
+
const newIndex = currentRowIndex + 1;
|
|
100
|
+
setCurrentRowIndex(newIndex);
|
|
101
|
+
const nextRow = filteredData[newIndex];
|
|
102
|
+
setSelectedRowJson(safeJsonStringify(nextRow));
|
|
103
|
+
setTimeout(() => {
|
|
104
|
+
setIsTransitioning(false);
|
|
105
|
+
}, 300);
|
|
106
|
+
}
|
|
107
|
+
}, [currentRowIndex, filteredData, isTransitioning]);
|
|
108
|
+
const goToPreviousRow = useCallback(() => {
|
|
109
|
+
if (isTransitioning)
|
|
110
|
+
return; // Protección contra clics rápidos
|
|
111
|
+
if (currentRowIndex > 0) {
|
|
112
|
+
setIsTransitioning(true);
|
|
113
|
+
const newIndex = currentRowIndex - 1;
|
|
114
|
+
setCurrentRowIndex(newIndex);
|
|
115
|
+
const prevRow = filteredData[newIndex];
|
|
116
|
+
setSelectedRowJson(safeJsonStringify(prevRow));
|
|
117
|
+
setTimeout(() => {
|
|
118
|
+
setIsTransitioning(false);
|
|
119
|
+
}, 300);
|
|
120
|
+
}
|
|
121
|
+
}, [currentRowIndex, filteredData, isTransitioning]);
|
|
122
|
+
const hasNextRow = currentRowIndex < filteredData.length - 1;
|
|
123
|
+
const hasPreviousRow = currentRowIndex > 0;
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
if (currentView === EDatabaseView.JSON_DETAIL && searchQuery !== previousSearchQuery) {
|
|
126
|
+
goBackFromJson();
|
|
127
|
+
setPreviousSearchQuery(searchQuery);
|
|
128
|
+
}
|
|
129
|
+
}, [searchQuery, previousSearchQuery, currentView, goBackFromJson]);
|
|
130
|
+
return (_jsx(DatabaseContext.Provider, { value: {
|
|
131
|
+
currentView,
|
|
132
|
+
tables,
|
|
133
|
+
data,
|
|
134
|
+
filteredData,
|
|
135
|
+
isLoading,
|
|
136
|
+
selectedTable,
|
|
137
|
+
selectedRowJson,
|
|
138
|
+
searchQuery,
|
|
139
|
+
currentRowIndex,
|
|
140
|
+
hasNextRow,
|
|
141
|
+
hasPreviousRow,
|
|
142
|
+
loadTables,
|
|
143
|
+
selectTable,
|
|
144
|
+
goBackFromRows,
|
|
145
|
+
selectRowJson,
|
|
146
|
+
goBackFromJson,
|
|
147
|
+
setSearchQuery,
|
|
148
|
+
goToNextRow,
|
|
149
|
+
goToPreviousRow,
|
|
150
|
+
}, children: children }));
|
|
151
|
+
}
|
|
152
|
+
export function useDatabase() {
|
|
153
|
+
const context = useContext(DatabaseContext);
|
|
154
|
+
if (!context) {
|
|
155
|
+
throw new Error("useDatabase must be used within DatabaseProvider");
|
|
156
|
+
}
|
|
157
|
+
return context;
|
|
158
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "nativewind/jsx-runtime";
|
|
2
|
+
import { Display } from "@sincpro/mobile-ui/Display";
|
|
3
|
+
import { Form } from "@sincpro/mobile-ui/Form";
|
|
4
|
+
import { theme } from "@sincpro/mobile-ui/theme";
|
|
5
|
+
import { Typography } from "@sincpro/mobile-ui/Typography";
|
|
6
|
+
import { FormViewV2 } from "@sincpro/mobile-ui/views/FormViewV2";
|
|
7
|
+
import JsonPreview from "@sincpro/mobile-ui/widgets/JSONViewer";
|
|
8
|
+
import * as Clipboard from "expo-clipboard";
|
|
9
|
+
import { View } from "react-native";
|
|
10
|
+
import { useDatabase } from "./database.context";
|
|
11
|
+
const Button = Form.Button;
|
|
12
|
+
const Icon = Display.Icon;
|
|
13
|
+
function JsonDetailView() {
|
|
14
|
+
const { selectedTable, selectedRowJson, goBackFromJson, currentRowIndex, filteredData, hasNextRow, hasPreviousRow, goToNextRow, goToPreviousRow, } = useDatabase();
|
|
15
|
+
return (_jsxs(FormViewV2.Root, { description: `JSON VIEWER - ${selectedTable}`, isLoading: false, item: { json: selectedRowJson }, name: "Detalles", onBack: goBackFromJson, children: [_jsx(FormViewV2.Header, { variant: "FLAT_HEADER" /* EVariantScreenHeader.FLAT_HEADER */, children: _jsx(FormViewV2.Header.Actions, { children: _jsxs(Typography.Text, { className: "text-gray-500", variant: "bodySmall", children: [currentRowIndex + 1, " de ", filteredData.length] }) }) }), _jsx(FormViewV2.Content, { children: _jsx(JsonPreview, { selectedJson: selectedRowJson }) }), _jsx(FormViewV2.Footer, { children: _jsxs(View, { className: "flex-row items-center justify-between gap-3", children: [_jsx(Button, { className: "flex-none min-w-[50px]", disabled: !hasPreviousRow, icon: _jsx(Icon, { color: hasPreviousRow ? theme.secondary : theme.text.tertiary, name: "chevron-left", size: 24, type: "feather" }), onPress: goToPreviousRow, title: "", variant: "secondary" }), _jsx(Button, { className: "flex-1", onPress: async () => {
|
|
16
|
+
await Clipboard.setStringAsync(selectedRowJson);
|
|
17
|
+
}, title: "Copiar JSON", variant: "primary" }), _jsx(Button, { className: "flex-none min-w-[50px]", disabled: !hasNextRow, icon: _jsx(Icon, { color: hasNextRow ? theme.secondary : theme.text.tertiary, name: "chevron-right", size: 24, type: "feather" }), onPress: goToNextRow, title: "", variant: "secondary" })] }) })] }));
|
|
18
|
+
}
|
|
19
|
+
export default JsonDetailView;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function DatabaseList(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "nativewind/jsx-runtime";
|
|
2
|
+
import DatabaseInfoRow from "../../../ui/components/organisms/DatabaseInfoRow";
|
|
3
|
+
import { ListViewV2 } from "@sincpro/mobile-ui/views/ListViewV2";
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { useNavigate } from "react-router-native";
|
|
6
|
+
import { DatabaseProvider, EDatabaseView, useDatabase } from "./database.context";
|
|
7
|
+
import JsonDetailView from "./database.json_detail";
|
|
8
|
+
import TableRowsView from "./database.table_rows";
|
|
9
|
+
function TablesView() {
|
|
10
|
+
const navigate = useNavigate();
|
|
11
|
+
const { loadTables, isLoading, tables, selectTable } = useDatabase();
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
void loadTables();
|
|
14
|
+
}, [loadTables]);
|
|
15
|
+
const onBack = () => navigate(-1);
|
|
16
|
+
return (_jsxs(ListViewV2.Root, { isLoading: isLoading, items: tables, name: "Lista de tablas", onBack: onBack, onPressItem: async (table) => {
|
|
17
|
+
await selectTable(table.name);
|
|
18
|
+
}, children: [_jsx(ListViewV2.Header, { variant: "FLAT_HEADER" /* EVariantScreenHeader.FLAT_HEADER */ }), _jsx(ListViewV2.Content, { children: (table) => (_jsx(DatabaseInfoRow, { item: {
|
|
19
|
+
name: table.displayName || table.name,
|
|
20
|
+
description: "Tabla de base de datos",
|
|
21
|
+
tableName: table.name,
|
|
22
|
+
}, onPress: async () => {
|
|
23
|
+
await selectTable(table.name);
|
|
24
|
+
} })) })] }));
|
|
25
|
+
}
|
|
26
|
+
function DatabaseListContent() {
|
|
27
|
+
const { currentView } = useDatabase();
|
|
28
|
+
switch (currentView) {
|
|
29
|
+
case EDatabaseView.TABLES_LIST:
|
|
30
|
+
return _jsx(TablesView, {});
|
|
31
|
+
case EDatabaseView.TABLE_ROWS:
|
|
32
|
+
return _jsx(TableRowsView, {});
|
|
33
|
+
case EDatabaseView.JSON_DETAIL:
|
|
34
|
+
return _jsx(JsonDetailView, {});
|
|
35
|
+
default:
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export default function DatabaseList() {
|
|
40
|
+
return (_jsx(DatabaseProvider, { children: _jsx(DatabaseListContent, {}) }));
|
|
41
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "nativewind/jsx-runtime";
|
|
2
|
+
import { safeJsonStringify } from "../../../tools/utils/serializer";
|
|
3
|
+
import TableInfoRow from "../../../ui/components/organisms/TableInfoInfoRow";
|
|
4
|
+
import { ListViewV2 } from "@sincpro/mobile-ui/views/ListViewV2";
|
|
5
|
+
import { useDatabase } from "./database.context";
|
|
6
|
+
function TableRowsView() {
|
|
7
|
+
const { isLoading, filteredData, selectedTable, goBackFromRows, selectRowJson, setSearchQuery, } = useDatabase();
|
|
8
|
+
return (_jsxs(ListViewV2.Root, { isLoading: isLoading, items: filteredData, name: `Datos - ${selectedTable}`, onBack: goBackFromRows, onPressItem: (item) => selectRowJson(safeJsonStringify(item), item.index), onSearch: setSearchQuery, children: [_jsx(ListViewV2.Header, { variant: "FLAT_HEADER" /* EVariantScreenHeader.FLAT_HEADER */, children: _jsx(ListViewV2.Header.Search, {}) }), _jsx(ListViewV2.Content, { children: (item) => (_jsx(TableInfoRow, { item: { data: safeJsonStringify(item) }, onPress: () => selectRowJson(safeJsonStringify(item), item.index) })) })] }));
|
|
9
|
+
}
|
|
10
|
+
export default TableRowsView;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DomainEvent } from "../../../domain/event_sourcing";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
interface IDeadLetterQueueContext {
|
|
4
|
+
events: DomainEvent[];
|
|
5
|
+
enrichedEvents: DomainEvent[];
|
|
6
|
+
selectedEvents: Set<string>;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
isRetrying: boolean;
|
|
9
|
+
isDeleting: boolean;
|
|
10
|
+
loadEvents: () => Promise<void>;
|
|
11
|
+
retryEvent: (event: DomainEvent) => Promise<void>;
|
|
12
|
+
retrySelectedEvents: () => Promise<{
|
|
13
|
+
success: number;
|
|
14
|
+
failed: number;
|
|
15
|
+
}>;
|
|
16
|
+
deleteEvent: (event: DomainEvent) => Promise<void>;
|
|
17
|
+
deleteSelectedEvents: () => Promise<{
|
|
18
|
+
success: number;
|
|
19
|
+
failed: number;
|
|
20
|
+
}>;
|
|
21
|
+
toggleSelection: (eventId: string) => void;
|
|
22
|
+
selectAll: () => void;
|
|
23
|
+
clearSelection: () => void;
|
|
24
|
+
loadMore: () => Promise<void>;
|
|
25
|
+
hasMore: boolean;
|
|
26
|
+
page: number;
|
|
27
|
+
pageSize: number;
|
|
28
|
+
isLoadingMore: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function DeadLetterQueueProvider({ children }: {
|
|
31
|
+
children: ReactNode;
|
|
32
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
export declare function useDeadLetterQueue(): IDeadLetterQueueContext;
|
|
34
|
+
export {};
|