strapi-content-sync-pro 1.0.2 → 1.0.3
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 +65 -18
- package/admin/src/components/ConfigTab.jsx +25 -4
- package/admin/src/components/HelpTab.jsx +88 -11
- package/admin/src/components/MediaTab.jsx +7 -0
- package/admin/src/components/StatsTab.jsx +470 -0
- package/admin/src/components/SyncProfilesTab.jsx +63 -5
- package/admin/src/components/SyncTab.jsx +51 -7
- package/admin/src/pages/App/index.jsx +3 -0
- package/docs/clipchamp-screen-recording-script.md +0 -0
- package/docs/production-readiness-status.md +34 -0
- package/docs/production-readiness-test-matrix.md +151 -0
- package/docs/test-environments-setup-legacy.txt +60 -0
- package/package.json +1 -1
- package/server/src/content-types/index.js +2 -0
- package/server/src/content-types/sync-run-report/schema.json +26 -0
- package/server/src/controllers/config.js +48 -5
- package/server/src/controllers/index.js +2 -0
- package/server/src/controllers/sync-log.js +6 -0
- package/server/src/controllers/sync-media.js +19 -0
- package/server/src/controllers/sync-stats.js +51 -0
- package/server/src/controllers/sync.js +9 -3
- package/server/src/routes/index.js +13 -0
- package/server/src/services/config.js +18 -2
- package/server/src/services/index.js +2 -0
- package/server/src/services/sync-execution.js +102 -5
- package/server/src/services/sync-log.js +36 -0
- package/server/src/services/sync-media.js +224 -1
- package/server/src/services/sync-profiles.js +92 -4
- package/server/src/services/sync-stats.js +353 -0
- package/server/src/services/sync.js +186 -100
- package/server/src/utils/applier.js +120 -13
- package/server/src/utils/comparator.js +22 -6
- package/server/src/utils/fetcher.js +11 -2
|
@@ -53,6 +53,7 @@ const SyncTab = () => {
|
|
|
53
53
|
const [executionStatus, setExecutionStatus] = useState([]);
|
|
54
54
|
const [globalSettings, setGlobalSettings] = useState({});
|
|
55
55
|
const [loading, setLoading] = useState(true);
|
|
56
|
+
const [syncMode, setSyncMode] = useState('paired');
|
|
56
57
|
|
|
57
58
|
// Filter and ordering
|
|
58
59
|
const [profileFilter, setProfileFilter] = useState('all');
|
|
@@ -84,17 +85,19 @@ const SyncTab = () => {
|
|
|
84
85
|
|
|
85
86
|
const loadData = async () => {
|
|
86
87
|
try {
|
|
87
|
-
const [profilesRes, statusRes, globalRes, depsRes] = await Promise.all([
|
|
88
|
+
const [profilesRes, statusRes, globalRes, depsRes, configRes] = await Promise.all([
|
|
88
89
|
get(`/${PLUGIN_ID}/sync-profiles`),
|
|
89
90
|
get(`/${PLUGIN_ID}/sync-execution/status`),
|
|
90
91
|
get(`/${PLUGIN_ID}/sync-execution/global-settings`),
|
|
91
92
|
get(`/${PLUGIN_ID}/dependencies/all`).catch(() => ({ data: { data: {} } })),
|
|
93
|
+
get(`/${PLUGIN_ID}/config`),
|
|
92
94
|
]);
|
|
93
95
|
const loadedProfiles = profilesRes.data.data || [];
|
|
94
96
|
setProfiles(loadedProfiles);
|
|
95
97
|
setExecutionStatus(statusRes.data.data || []);
|
|
96
98
|
setGlobalSettings(globalRes.data.data || {});
|
|
97
99
|
setDependencies(depsRes.data.data || {});
|
|
100
|
+
setSyncMode(configRes?.data?.data?.syncMode || 'paired');
|
|
98
101
|
|
|
99
102
|
// Load saved execution order or calculate from dependencies
|
|
100
103
|
const savedOrder = globalRes.data.data?.executionOrder || {};
|
|
@@ -325,7 +328,7 @@ const SyncTab = () => {
|
|
|
325
328
|
const openSettingsModal = async (profileId) => {
|
|
326
329
|
try {
|
|
327
330
|
const res = await get(`/${PLUGIN_ID}/sync-execution/settings/${profileId}`);
|
|
328
|
-
|
|
331
|
+
const settings = res.data.data || {
|
|
329
332
|
executionMode: 'on_demand',
|
|
330
333
|
scheduleType: 'interval',
|
|
331
334
|
scheduleInterval: 60,
|
|
@@ -333,7 +336,15 @@ const SyncTab = () => {
|
|
|
333
336
|
enabled: false,
|
|
334
337
|
syncDependencies: false,
|
|
335
338
|
dependencyDepth: 1,
|
|
336
|
-
}
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
const profile = profiles.find((p) => p.id === profileId);
|
|
342
|
+
if (profile && profile.syncDeletions && settings.executionMode === 'live') {
|
|
343
|
+
settings.executionMode = 'on_demand';
|
|
344
|
+
settings.enabled = false;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
setExecutionSettings(settings);
|
|
337
348
|
setSelectedProfile(profileId);
|
|
338
349
|
setSettingsModalOpen(true);
|
|
339
350
|
} catch (err) {
|
|
@@ -343,7 +354,19 @@ const SyncTab = () => {
|
|
|
343
354
|
|
|
344
355
|
const handleSaveExecutionSettings = async () => {
|
|
345
356
|
try {
|
|
346
|
-
|
|
357
|
+
const payload = { ...executionSettings };
|
|
358
|
+
if (syncMode === 'single_side' && payload.executionMode === 'live') {
|
|
359
|
+
payload.executionMode = 'on_demand';
|
|
360
|
+
payload.enabled = false;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
const selected = profiles.find((p) => p.id === selectedProfile);
|
|
364
|
+
if (selected?.syncDeletions && payload.executionMode === 'live') {
|
|
365
|
+
payload.executionMode = 'on_demand';
|
|
366
|
+
payload.enabled = false;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
await put(`/${PLUGIN_ID}/sync-execution/settings/${selectedProfile}`, payload);
|
|
347
370
|
setMessage({ type: 'success', text: 'Execution settings saved' });
|
|
348
371
|
setSettingsModalOpen(false);
|
|
349
372
|
loadData();
|
|
@@ -441,6 +464,22 @@ const SyncTab = () => {
|
|
|
441
464
|
</Flex>
|
|
442
465
|
</Flex>
|
|
443
466
|
|
|
467
|
+
{syncMode === 'single_side' && (
|
|
468
|
+
<Box paddingTop={4}>
|
|
469
|
+
<Alert variant="info" title="Single-side mode restrictions">
|
|
470
|
+
Live execution is disabled in single-side mode. Use on-demand or scheduled execution with pull-only profiles.
|
|
471
|
+
</Alert>
|
|
472
|
+
</Box>
|
|
473
|
+
)}
|
|
474
|
+
|
|
475
|
+
{profiles.some((p) => p.syncDeletions) && (
|
|
476
|
+
<Box paddingTop={4}>
|
|
477
|
+
<Alert variant="info" title="Deletion sync profile rules">
|
|
478
|
+
Profiles with deletion sync enabled run as explicit one-way operations. Avoid live mode for these profiles.
|
|
479
|
+
</Alert>
|
|
480
|
+
</Box>
|
|
481
|
+
)}
|
|
482
|
+
|
|
444
483
|
{message && (
|
|
445
484
|
<Box paddingTop={4}>
|
|
446
485
|
<Alert variant={message.type} closeLabel="Close" onClose={() => setMessage(null)}>
|
|
@@ -474,7 +513,7 @@ const SyncTab = () => {
|
|
|
474
513
|
value={profileFilter}
|
|
475
514
|
onChange={setProfileFilter}
|
|
476
515
|
size="S"
|
|
477
|
-
style={{ width:
|
|
516
|
+
style={{ width: 180 }}
|
|
478
517
|
>
|
|
479
518
|
{FILTER_OPTIONS.map(opt => (
|
|
480
519
|
<SingleSelectOption key={opt.value} value={opt.value}>
|
|
@@ -570,7 +609,7 @@ const SyncTab = () => {
|
|
|
570
609
|
<ArrowDown />
|
|
571
610
|
</IconButton>
|
|
572
611
|
</Flex>
|
|
573
|
-
<TextInput
|
|
612
|
+
<TextInput
|
|
574
613
|
value={order}
|
|
575
614
|
onChange={(e) => handleOrderChange(profile.id, e.target.value)}
|
|
576
615
|
style={{ width: 50, textAlign: 'center' }}
|
|
@@ -849,7 +888,11 @@ const SyncTab = () => {
|
|
|
849
888
|
onChange={(value) => setExecutionSettings((p) => ({ ...p, executionMode: value }))}
|
|
850
889
|
>
|
|
851
890
|
{EXECUTION_MODE_OPTIONS.map((opt) => (
|
|
852
|
-
<SingleSelectOption
|
|
891
|
+
<SingleSelectOption
|
|
892
|
+
key={opt.value}
|
|
893
|
+
value={opt.value}
|
|
894
|
+
disabled={syncMode === 'single_side' && opt.value === 'live'}
|
|
895
|
+
>
|
|
853
896
|
{opt.label}
|
|
854
897
|
</SingleSelectOption>
|
|
855
898
|
))}
|
|
@@ -858,6 +901,7 @@ const SyncTab = () => {
|
|
|
858
901
|
{executionSettings.executionMode === 'on_demand' && 'Sync only when manually triggered'}
|
|
859
902
|
{executionSettings.executionMode === 'scheduled' && 'Sync automatically at regular intervals'}
|
|
860
903
|
{executionSettings.executionMode === 'live' && 'Sync immediately when changes occur'}
|
|
904
|
+
{syncMode === 'single_side' && executionSettings.executionMode === 'live' && ' (not supported in single-side mode)'}
|
|
861
905
|
</Field.Hint>
|
|
862
906
|
</Field.Root>
|
|
863
907
|
</Box>
|
|
@@ -6,6 +6,7 @@ import { ConfigTab } from '../../components/ConfigTab';
|
|
|
6
6
|
import { ContentTypesTab } from '../../components/ContentTypesTab';
|
|
7
7
|
import { SyncTab } from '../../components/SyncTab';
|
|
8
8
|
import { LogsTab } from '../../components/LogsTab';
|
|
9
|
+
import { StatsTab } from '../../components/StatsTab';
|
|
9
10
|
import { HelpTab } from '../../components/HelpTab';
|
|
10
11
|
import { SyncProfilesTab } from '../../components/SyncProfilesTab';
|
|
11
12
|
import { MediaTab } from '../../components/MediaTab';
|
|
@@ -16,6 +17,7 @@ const TABS = [
|
|
|
16
17
|
{ key: 'sync-profiles', label: 'Sync Profiles' },
|
|
17
18
|
{ key: 'sync', label: 'Sync' },
|
|
18
19
|
{ key: 'media', label: 'Media' },
|
|
20
|
+
{ key: 'stats', label: 'Stats' },
|
|
19
21
|
{ key: 'logs', label: 'Logs' },
|
|
20
22
|
{ key: 'help', label: 'Help' },
|
|
21
23
|
];
|
|
@@ -50,6 +52,7 @@ const HomePage = () => {
|
|
|
50
52
|
{activeTab === 'sync-profiles' && <SyncProfilesTab />}
|
|
51
53
|
{activeTab === 'sync' && <SyncTab />}
|
|
52
54
|
{activeTab === 'media' && <MediaTab />}
|
|
55
|
+
{activeTab === 'stats' && <StatsTab />}
|
|
53
56
|
{activeTab === 'logs' && <LogsTab />}
|
|
54
57
|
{activeTab === 'help' && <HelpTab />}
|
|
55
58
|
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Production Readiness Status — Content Sync Pro
|
|
2
|
+
|
|
3
|
+
## Current Verdict
|
|
4
|
+
**NO-GO (not yet fully production-ready)**
|
|
5
|
+
|
|
6
|
+
## Completed
|
|
7
|
+
- Implemented paired/single-side mode behavior and enforcement.
|
|
8
|
+
- Implemented Stats tab + before/after run reports.
|
|
9
|
+
- Implemented manual clear + retention limits for logs/reports.
|
|
10
|
+
- Added production-readiness test matrix:
|
|
11
|
+
- `docs/production-readiness-test-matrix.md`
|
|
12
|
+
- Added legacy environment notes copy:
|
|
13
|
+
- `docs/test-environments-setup-legacy.txt`
|
|
14
|
+
|
|
15
|
+
## Smoke Checks Passed
|
|
16
|
+
- `GET http://localhost:40101/api/strapi-content-sync-pro/ping` => 200
|
|
17
|
+
- `GET http://localhost:4010/api/strapi-content-sync-pro/ping` => 200
|
|
18
|
+
- Package test script passes (`npm run test`) — placeholder only.
|
|
19
|
+
|
|
20
|
+
## Blocking Items Before GO
|
|
21
|
+
1. Execute full P0 and P1 matrix scenarios in `docs/production-readiness-test-matrix.md`.
|
|
22
|
+
2. Capture evidence for each case (request/response, DB/file verification, screenshots).
|
|
23
|
+
3. Verify restart/recovery after plugin copy in target runtime path.
|
|
24
|
+
4. Validate single-side mode with remote plugin disabled.
|
|
25
|
+
5. Validate media restore scenarios after partial deletions.
|
|
26
|
+
6. Confirm retention pruning under load (high log/report volume).
|
|
27
|
+
|
|
28
|
+
## Required Release Gate
|
|
29
|
+
- P0 cases: 100% pass
|
|
30
|
+
- P1 cases: pass or accepted risk signed off
|
|
31
|
+
- No open critical defects
|
|
32
|
+
|
|
33
|
+
## Recommended Next Action
|
|
34
|
+
Run matrix execution in order: P0 -> P1 -> P2, then update this file with final **GO/NO-GO** sign-off.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# Content Sync Pro — Production Readiness Test Matrix
|
|
2
|
+
|
|
3
|
+
This guide converts the environment notes from `test-enviroments-setup.txt` into a structured, repeatable validation matrix for release readiness.
|
|
4
|
+
|
|
5
|
+
## 1) Test Environments
|
|
6
|
+
|
|
7
|
+
### Remote Server
|
|
8
|
+
- Start:
|
|
9
|
+
- `D:\Rutba\ERP> npm run dev:strapi`
|
|
10
|
+
- URL: `http://localhost:4010`
|
|
11
|
+
- DB: MySQL (`pos_db`)
|
|
12
|
+
- Upload dir: `D:\Rutba\data\rutba-pos-files\uploads`
|
|
13
|
+
|
|
14
|
+
### Local Server
|
|
15
|
+
- Start:
|
|
16
|
+
- `D:\Rutba\ERP\pos-strapi> npm run dev`
|
|
17
|
+
- URL: `http://localhost:40101`
|
|
18
|
+
- DB: MySQL (`rutba_pos`)
|
|
19
|
+
- Upload dir: `D:\Rutba\data\rutba-pos-files\tmp\uploads`
|
|
20
|
+
|
|
21
|
+
### Shared Notes
|
|
22
|
+
- Same Strapi codebase, different `.env` values.
|
|
23
|
+
- Admin credentials (both):
|
|
24
|
+
- Email: `eharain@yahoo.com`
|
|
25
|
+
- Password: `At56ZNTxXf6JSTq`
|
|
26
|
+
- Plugin deploy target to test runtime updates:
|
|
27
|
+
- `D:\Rutba\ERP\pos-strapi\src\plugins\strapi-content-sync-pro`
|
|
28
|
+
- Restart may be required after plugin copy/update.
|
|
29
|
+
|
|
30
|
+
## 2) Scope of Validation
|
|
31
|
+
|
|
32
|
+
- Paired mode (plugin installed both sides)
|
|
33
|
+
- Single-side mode (plugin active on local only)
|
|
34
|
+
- Profiles (simple + advanced), dependency depth, execution modes
|
|
35
|
+
- Entity sync (CMS content, products, orders)
|
|
36
|
+
- Media sync + entity-linked media
|
|
37
|
+
- Stats tab snapshots and before/after reports
|
|
38
|
+
- Log/report retention and cleanup controls
|
|
39
|
+
- Failure/recovery behavior
|
|
40
|
+
|
|
41
|
+
## 3) Pass/Fail Exit Criteria
|
|
42
|
+
|
|
43
|
+
A build is **production-ready** only if all are true:
|
|
44
|
+
- Critical test cases pass (P0/P1 below)
|
|
45
|
+
- No data corruption in local/remote DBs
|
|
46
|
+
- No orphaned media references after sync runs
|
|
47
|
+
- Stats/report data is generated and retention controls work
|
|
48
|
+
- Plugin starts cleanly after restart in tested configurations
|
|
49
|
+
|
|
50
|
+
## 4) Test Matrix
|
|
51
|
+
|
|
52
|
+
| ID | Priority | Area | Scenario | Setup | Steps | Expected Result | Status | Evidence |
|
|
53
|
+
|---|---|---|---|---|---|---|---|---|
|
|
54
|
+
| P0-01 | P0 | Health | Plugin ping reachable both servers (paired) | Both running with plugin enabled | Call `/api/strapi-content-sync-pro/ping` on :40101 and :4010 | HTTP 200 + `{ "status": "ok" }` | TODO | |
|
|
55
|
+
| P0-02 | P0 | Connection | Connection test in paired mode | Local configured to remote | Run **Test Connection** in Configuration tab | Success, plugin endpoint validated | TODO | |
|
|
56
|
+
| P0-03 | P0 | Single-side | Connection test in single-side mode | Disable remote plugin load via env | Set local mode `single_side`, run Test Connection | Success without requiring remote plugin routes | TODO | |
|
|
57
|
+
| P0-04 | P0 | Profiles | Pull-only enforcement in single-side | Local mode `single_side` | Try creating push/bidirectional profile | UI/API enforce pull-only | TODO | |
|
|
58
|
+
| P0-05 | P0 | Execution | Live mode blocked in single-side | Local mode `single_side` | Try saving execution mode `live` | Rejected or normalized to non-live | TODO | |
|
|
59
|
+
| P0-06 | P0 | Data | Orders remote → local sync | Create new orders on remote | Run local pull/sync | Orders and order details appear local | TODO | |
|
|
60
|
+
| P0-07 | P0 | Data | CMS/offers local → remote sync (paired) | Create CMS/offers local | Run push/bidirectional | Entries appear remote correctly | TODO | |
|
|
61
|
+
| P0-08 | P0 | Media | Entity-linked media sync | Attach media to products/CMS | Run sync profile + media sync | Files + DB refs consistent on target | TODO | |
|
|
62
|
+
| P0-09 | P0 | Stats | Pre/post run report generation | Any enabled content types | Trigger sync run | Stats report contains before/after snapshots | TODO | |
|
|
63
|
+
| P0-10 | P0 | Retention | Manual clear logs/reports | Existing logs/reports | Use clear actions in Stats tab | Data removed, UI refreshed | TODO | |
|
|
64
|
+
| P1-01 | P1 | Dependencies | Min depth profile run | Profile depth=1 | Run profile | Only first-level dependencies handled | TODO | |
|
|
65
|
+
| P1-02 | P1 | Dependencies | Max depth profile run | Profile depth=5 | Run profile | Deep dependencies handled; no crash | TODO | |
|
|
66
|
+
| P1-03 | P1 | Media Recovery | Recreate deleted local media from remote | Delete selected local media rows/files | Run downward sync | Missing media restored | TODO | |
|
|
67
|
+
| P1-04 | P1 | Conflict | Latest/local/remote strategy behavior | Divergent edits both sides | Run with each strategy | Winner follows selected policy | TODO | |
|
|
68
|
+
| P1-05 | P1 | Restart | Restart resilience | Update plugin files + restart | Restart both servers | Plugin loads without route/service errors | TODO | |
|
|
69
|
+
| P1-06 | P1 | Retention Auto | Pruning by max entries | Set low limits | Trigger retention run | Old logs/reports pruned to limit | TODO | |
|
|
70
|
+
| P2-01 | P2 | Performance | Large dataset pagination behavior | Seed high row count | Run sync with page-size variations | Completes with bounded memory/errors | TODO | |
|
|
71
|
+
| P2-02 | P2 | UX | Stats readability | Run several syncs | Review report history | Clear before/after trend visibility | TODO | |
|
|
72
|
+
|
|
73
|
+
## 5) Detailed Execution Checklist
|
|
74
|
+
|
|
75
|
+
### A. Baseline + Connectivity
|
|
76
|
+
1. Confirm both servers are running.
|
|
77
|
+
2. Verify paired mode ping endpoints.
|
|
78
|
+
3. Configure local plugin connection settings.
|
|
79
|
+
4. Validate **Test Connection** in paired mode.
|
|
80
|
+
|
|
81
|
+
### B. Single-side Mode
|
|
82
|
+
1. Disable plugin loading on remote using env flag.
|
|
83
|
+
2. Keep local plugin enabled.
|
|
84
|
+
3. Set local `syncMode = single_side`.
|
|
85
|
+
4. Run connection test and verify success without remote plugin route dependency.
|
|
86
|
+
5. Verify profile direction and execution mode restrictions.
|
|
87
|
+
|
|
88
|
+
### C. Data Sync Scenarios
|
|
89
|
+
1. Create products with variations on source side; sync and verify target.
|
|
90
|
+
2. Create orders on remote; pull to local and verify details.
|
|
91
|
+
3. Create CMS content/offers local; push to remote and verify.
|
|
92
|
+
4. Run scenarios with different conflict strategies.
|
|
93
|
+
|
|
94
|
+
### D. Media Scenarios
|
|
95
|
+
1. Upload media and attach to products/CMS entities.
|
|
96
|
+
2. Sync and verify both file presence and DB links.
|
|
97
|
+
3. Delete a subset of local media rows/files.
|
|
98
|
+
4. Re-run downward sync; confirm restoration.
|
|
99
|
+
|
|
100
|
+
### E. Stats + Retention
|
|
101
|
+
1. Trigger sync; confirm report with before/after snapshots appears.
|
|
102
|
+
2. Verify columns: local/remote count, newest timestamps, newest side.
|
|
103
|
+
3. Use manual clear for logs and reports.
|
|
104
|
+
4. Configure low retention limits and run retention; verify pruning.
|
|
105
|
+
|
|
106
|
+
### F. Restart/Recovery
|
|
107
|
+
1. Copy plugin changes into Strapi plugin destination.
|
|
108
|
+
2. Restart both instances.
|
|
109
|
+
3. Re-check critical routes and one sync run.
|
|
110
|
+
|
|
111
|
+
## 6) Evidence Template
|
|
112
|
+
|
|
113
|
+
For each executed case, capture:
|
|
114
|
+
- Timestamp
|
|
115
|
+
- Server mode (paired/single-side)
|
|
116
|
+
- Profile ID/name and execution mode
|
|
117
|
+
- Request/response snippets (or screenshots)
|
|
118
|
+
- DB/file verification notes
|
|
119
|
+
- Result: Pass/Fail + defect link
|
|
120
|
+
|
|
121
|
+
Example note:
|
|
122
|
+
- `P0-09` | `2026-04-21 10:20` | `Pass`
|
|
123
|
+
- Report ID: `...`
|
|
124
|
+
- Before: products local=120 remote=115 newest=local
|
|
125
|
+
- After: products local=120 remote=120 newest=equal
|
|
126
|
+
|
|
127
|
+
## 7) Defect Severity Guidance
|
|
128
|
+
|
|
129
|
+
- **Critical**: Data loss/corruption, wrong direction writes, plugin cannot start
|
|
130
|
+
- **High**: Core sync path broken for common scenario
|
|
131
|
+
- **Medium**: Stats/reporting incorrect but sync still reliable
|
|
132
|
+
- **Low**: UI copy/formatting issues
|
|
133
|
+
|
|
134
|
+
## 8) Go/No-Go Summary
|
|
135
|
+
|
|
136
|
+
- Total cases executed:
|
|
137
|
+
- Passed:
|
|
138
|
+
- Failed:
|
|
139
|
+
- Blocked:
|
|
140
|
+
- Critical open defects:
|
|
141
|
+
- Decision: **GO / NO-GO**
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Current Session Smoke Result
|
|
146
|
+
|
|
147
|
+
- Ping local (`:40101`) = PASS
|
|
148
|
+
- Ping remote (`:4010`) = PASS
|
|
149
|
+
- Package test script (`npm run test`) = PASS (`No tests yet` placeholder)
|
|
150
|
+
|
|
151
|
+
A full production readiness sign-off requires completion of the matrix above.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
|
|
2
|
+
Remote server :
|
|
3
|
+
D:\>cd d:\Rutba\ERP
|
|
4
|
+
D:\Rutba\ERP>npm run dev:strapi
|
|
5
|
+
|
|
6
|
+
Database = mysql
|
|
7
|
+
Database name = pos_db
|
|
8
|
+
URL= http://localhost:4010
|
|
9
|
+
Upload dir =D:\Rutba\data\rutba-pos-files\uploads
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
Local Server:
|
|
15
|
+
D:\Rutba\ERP>cd pos-strapi
|
|
16
|
+
D:\Rutba\ERP\pos-strapi>npm run dev
|
|
17
|
+
http://localhost:40101
|
|
18
|
+
|
|
19
|
+
Database = mysql │
|
|
20
|
+
Database name = rutba_pos
|
|
21
|
+
Upload Dir = D:\Rutba\data\rutba-pos-files\tmp\uploads
|
|
22
|
+
|
|
23
|
+
these two servers have same code base of strapi but are running using different .env settings
|
|
24
|
+
|
|
25
|
+
you can truncate or partially delete any of their database tables or enteries as well as files.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
Please note that when the files are copied over the instance try to reboot but any of these can fail to start so you will have to restart. the restart takes about a minutes each time.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Both the servers admin user : eharain@yahoo.com and password : At56ZNTxXf6JSTq
|
|
33
|
+
|
|
34
|
+
kindly test different settings and different variations and ensure that the plugin works as desired.
|
|
35
|
+
|
|
36
|
+
the current servers are running in command prompt and you can stop them by pressing ctrl+c and start them again using the above commands. you can run these servers in you own power shels if you want.
|
|
37
|
+
the servers will not restrt unloss you copy the code changes in destination drrectory of the plugin that is :D:\Rutba\ERP\pos-strapi\src\plugins\strapi-content-sync-pro
|
|
38
|
+
|
|
39
|
+
to understand the entites read the contents of any server or in src directory of the strapi.
|
|
40
|
+
|
|
41
|
+
to test single-side mode disable the plugin loading by a special enviromment variable so that specific spin of strapi will not load the plugin and then you can test the sync in one direction.
|
|
42
|
+
|
|
43
|
+
Tests:
|
|
44
|
+
kindly create different sync profiles with least and max dependiceis and depth and try executing them.
|
|
45
|
+
|
|
46
|
+
kindly few media files and then sync also upload connect to entites and then sync and check if the media files are also synced properly with the entities.
|
|
47
|
+
|
|
48
|
+
Please also test the sync with different data in the tables and check if the sync is working as expected.
|
|
49
|
+
|
|
50
|
+
insert test data specially cms entites and then sync and check if the data is synced properly in the destination server.
|
|
51
|
+
|
|
52
|
+
create products and test the sync with different variations of products and check if the products are synced properly in the destination server.
|
|
53
|
+
|
|
54
|
+
create orders and test the sync with different variations of orders and check if the orders are synced properly in the destination server.
|
|
55
|
+
|
|
56
|
+
the orders will be created on remote server and should be synced to local server and then you can check the orders in local server and also check the order details and the products in the order and the media files connected to the products in the order.
|
|
57
|
+
|
|
58
|
+
the cms contenst and offers are created on local servers and set to remote server and then you can check the cms content and offers in remote server and also check the media files connected to the cms content and offers.
|
|
59
|
+
|
|
60
|
+
complete remove media enteries and few files on local server and then sync downward and check if these are created again. simmilar create new media each side and sync across.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strapi-content-sync-pro",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Strapi v5 plugin to copy, migrate, and live-sync content, media, and data between multiple Strapi environments with bi-directional sync, field-level policies, scheduling, and alerts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const syncLogSchema = require('./sync-log/schema.json');
|
|
4
|
+
const syncRunReportSchema = require('./sync-run-report/schema.json');
|
|
4
5
|
|
|
5
6
|
module.exports = {
|
|
6
7
|
'sync-log': { schema: syncLogSchema },
|
|
8
|
+
'sync-run-report': { schema: syncRunReportSchema },
|
|
7
9
|
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "collectionType",
|
|
3
|
+
"collectionName": "sync_run_reports",
|
|
4
|
+
"info": {
|
|
5
|
+
"singularName": "sync-run-report",
|
|
6
|
+
"pluralName": "sync-run-reports",
|
|
7
|
+
"displayName": "Sync Run Report"
|
|
8
|
+
},
|
|
9
|
+
"options": {},
|
|
10
|
+
"pluginOptions": {
|
|
11
|
+
"content-manager": { "visible": false },
|
|
12
|
+
"content-type-builder": { "visible": false }
|
|
13
|
+
},
|
|
14
|
+
"attributes": {
|
|
15
|
+
"runType": { "type": "string" },
|
|
16
|
+
"trigger": { "type": "string" },
|
|
17
|
+
"status": { "type": "string" },
|
|
18
|
+
"startedAt": { "type": "datetime" },
|
|
19
|
+
"completedAt": { "type": "datetime" },
|
|
20
|
+
"contentTypes": { "type": "json" },
|
|
21
|
+
"beforeStats": { "type": "json" },
|
|
22
|
+
"afterStats": { "type": "json" },
|
|
23
|
+
"summary": { "type": "json" },
|
|
24
|
+
"error": { "type": "text" }
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -38,8 +38,50 @@ module.exports = {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
const syncMode = config.syncMode || 'paired';
|
|
42
|
+
|
|
43
|
+
// Step 1: Basic reachability
|
|
42
44
|
const startTime = Date.now();
|
|
45
|
+
if (syncMode === 'single_side') {
|
|
46
|
+
try {
|
|
47
|
+
const reachRes = await fetch(`${config.baseUrl}/api`, {
|
|
48
|
+
method: 'GET',
|
|
49
|
+
headers: { Authorization: `Bearer ${config.apiToken}` },
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (reachRes.status === 401 || reachRes.status === 403) {
|
|
53
|
+
return ctx.body = {
|
|
54
|
+
data: {
|
|
55
|
+
success: false,
|
|
56
|
+
stage: 'auth',
|
|
57
|
+
message: `API token rejected by remote server (${reachRes.status}). Verify the token is valid and can read target content APIs.`,
|
|
58
|
+
latency: Date.now() - startTime,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
} catch (err) {
|
|
63
|
+
return ctx.body = {
|
|
64
|
+
data: {
|
|
65
|
+
success: false,
|
|
66
|
+
stage: 'network',
|
|
67
|
+
message: `Cannot reach remote server in single-side mode: ${err.message}`,
|
|
68
|
+
latency: Date.now() - startTime,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return ctx.body = {
|
|
74
|
+
data: {
|
|
75
|
+
success: true,
|
|
76
|
+
stage: 'complete',
|
|
77
|
+
message: 'Connection successful in single-side mode. Remote plugin endpoints are not required; only remote content APIs and token access are validated.',
|
|
78
|
+
latency: Date.now() - startTime,
|
|
79
|
+
remoteInfo: null,
|
|
80
|
+
mode: syncMode,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
43
85
|
let pingStatus = null;
|
|
44
86
|
try {
|
|
45
87
|
const pingRes = await fetch(`${config.baseUrl}/api/${PLUGIN_ID}/ping`, {
|
|
@@ -69,7 +111,7 @@ module.exports = {
|
|
|
69
111
|
|
|
70
112
|
const pingLatency = Date.now() - startTime;
|
|
71
113
|
|
|
72
|
-
// Step 2: Verify API token works against an authenticated endpoint
|
|
114
|
+
// Step 2: Verify API token works against an authenticated plugin endpoint
|
|
73
115
|
let authWorks = false;
|
|
74
116
|
let remoteInfo = null;
|
|
75
117
|
try {
|
|
@@ -116,10 +158,11 @@ module.exports = {
|
|
|
116
158
|
success: true,
|
|
117
159
|
stage: 'complete',
|
|
118
160
|
message: authWorks
|
|
119
|
-
? 'Connection successful and API token
|
|
161
|
+
? 'Connection successful: remote plugin is reachable and API token is valid. Ensure matching sync settings (content types, active profiles, execution mode, and shared secret) on both servers before running sync.'
|
|
120
162
|
: 'Reachable but API token could not be validated',
|
|
121
163
|
latency: pingLatency,
|
|
122
164
|
remoteInfo,
|
|
165
|
+
mode: syncMode,
|
|
123
166
|
},
|
|
124
167
|
};
|
|
125
168
|
},
|
|
@@ -251,10 +294,10 @@ module.exports = {
|
|
|
251
294
|
// Step 4: Optionally get remote instance ID if plugin is installed
|
|
252
295
|
let remoteInstanceId = null;
|
|
253
296
|
try {
|
|
254
|
-
const remoteConfigResponse = await fetch(`${baseUrl}/
|
|
297
|
+
const remoteConfigResponse = await fetch(`${baseUrl}/strapi-content-sync-pro/config`, {
|
|
255
298
|
method: 'GET',
|
|
256
299
|
headers: {
|
|
257
|
-
Authorization: `Bearer ${
|
|
300
|
+
Authorization: `Bearer ${adminJwt}`,
|
|
258
301
|
},
|
|
259
302
|
});
|
|
260
303
|
|
|
@@ -12,6 +12,7 @@ const syncEnforcement = require('./sync-enforcement');
|
|
|
12
12
|
const syncMedia = require('./sync-media');
|
|
13
13
|
const alerts = require('./alerts');
|
|
14
14
|
const dependencies = require('./dependencies');
|
|
15
|
+
const syncStats = require('./sync-stats');
|
|
15
16
|
|
|
16
17
|
module.exports = {
|
|
17
18
|
ping,
|
|
@@ -26,4 +27,5 @@ module.exports = {
|
|
|
26
27
|
syncMedia,
|
|
27
28
|
alerts,
|
|
28
29
|
dependencies,
|
|
30
|
+
syncStats,
|
|
29
31
|
};
|
|
@@ -111,6 +111,25 @@ module.exports = ({ strapi }) => ({
|
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
113
|
|
|
114
|
+
// ── Morph link sync (documentId-based mapping) ───────────────────────────
|
|
115
|
+
|
|
116
|
+
async getMorphLinks(ctx) {
|
|
117
|
+
try {
|
|
118
|
+
ctx.body = { data: await service(strapi).exportMorphLinks() };
|
|
119
|
+
} catch (err) {
|
|
120
|
+
ctx.throw(500, err.message);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
async applyMorphLinks(ctx) {
|
|
125
|
+
try {
|
|
126
|
+
const links = ctx.request.body?.links || [];
|
|
127
|
+
ctx.body = { data: await service(strapi).applyMorphLinks(links) };
|
|
128
|
+
} catch (err) {
|
|
129
|
+
ctx.throw(400, err.message);
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
|
|
114
133
|
// ── Back-compat (old flat endpoints) ──────────────────────────────────────
|
|
115
134
|
|
|
116
135
|
async getSettings(ctx) {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const PLUGIN_ID = 'strapi-content-sync-pro';
|
|
4
|
+
|
|
5
|
+
module.exports = ({ strapi }) => ({
|
|
6
|
+
async getSnapshot(ctx) {
|
|
7
|
+
try {
|
|
8
|
+
const data = await strapi.plugin(PLUGIN_ID).service('syncStats').getLatestSnapshot();
|
|
9
|
+
ctx.body = { data };
|
|
10
|
+
} catch (err) {
|
|
11
|
+
ctx.throw(500, err.message);
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
async getReports(ctx) {
|
|
16
|
+
const { page, pageSize } = ctx.query;
|
|
17
|
+
try {
|
|
18
|
+
const data = await strapi.plugin(PLUGIN_ID).service('syncStats').getReports({
|
|
19
|
+
page: page ? parseInt(page, 10) : 1,
|
|
20
|
+
pageSize: pageSize ? parseInt(pageSize, 10) : 10,
|
|
21
|
+
});
|
|
22
|
+
ctx.body = data;
|
|
23
|
+
} catch (err) {
|
|
24
|
+
ctx.throw(500, err.message);
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
async clearReports(ctx) {
|
|
29
|
+
try {
|
|
30
|
+
const result = await strapi.plugin(PLUGIN_ID).service('syncStats').clearReports();
|
|
31
|
+
ctx.body = { data: result };
|
|
32
|
+
} catch (err) {
|
|
33
|
+
ctx.throw(500, err.message);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
async runRetention(ctx) {
|
|
38
|
+
const body = ctx.request.body || {};
|
|
39
|
+
try {
|
|
40
|
+
const syncStats = strapi.plugin(PLUGIN_ID).service('syncStats');
|
|
41
|
+
const syncLog = strapi.plugin(PLUGIN_ID).service('syncLog');
|
|
42
|
+
const reports = await syncStats.applyRetention({ maxReports: body.maxReports });
|
|
43
|
+
const logs = await syncLog.applyRetention({ maxLogs: body.maxLogs });
|
|
44
|
+
ctx.body = { data: { reports, logs } };
|
|
45
|
+
} catch (err) {
|
|
46
|
+
ctx.throw(400, err.message);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
});
|
|
@@ -15,14 +15,20 @@ module.exports = {
|
|
|
15
15
|
async receive(ctx) {
|
|
16
16
|
const { body } = ctx.request;
|
|
17
17
|
|
|
18
|
-
if (!body || !body.uid || !body.syncId) {
|
|
19
|
-
return ctx.badRequest('Missing uid, data, or syncId');
|
|
18
|
+
if (!body || !body.uid || (!body.syncId && !body.documentId)) {
|
|
19
|
+
return ctx.badRequest('Missing uid, data, or documentId/syncId');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
const syncService = strapi.plugin('strapi-content-sync-pro').service('sync');
|
|
23
23
|
|
|
24
24
|
try {
|
|
25
|
-
const result = await syncService.receiveRecord(
|
|
25
|
+
const result = await syncService.receiveRecord(
|
|
26
|
+
body.uid,
|
|
27
|
+
body.data || {},
|
|
28
|
+
body.syncId || null,
|
|
29
|
+
!!body.delete,
|
|
30
|
+
body.documentId || null,
|
|
31
|
+
);
|
|
26
32
|
ctx.body = { data: result };
|
|
27
33
|
} catch (err) {
|
|
28
34
|
return ctx.badRequest(err.message);
|