@biglogic/rgs 3.7.6 → 3.7.9

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.
@@ -1,146 +1,146 @@
1
- # 🚀 Chapter 10: Local-First Sync Engine
2
-
3
- RGS now includes a powerful **Local-First Sync Engine** that makes your app work offline by default and automatically synchronize when connectivity is restored.
4
-
5
- ## Why Local-First?
6
-
7
- Traditional apps require an internet connection to work. Local-First apps work immediately with local data and sync in the background when possible.
8
-
9
- ### Benefits
10
-
11
- - **Instant Load** - No waiting for server responses
12
- - **Works Offline** - App functions without internet
13
- - **Better UX** - No loading spinners for data
14
- - **Conflict Resolution** - Smart merge strategies
15
-
16
- ## Quick Start
17
-
18
- ```typescript
19
- import { gstate, useSyncedState } from '@biglogic/rgs'
20
-
21
- // Create store with sync enabled
22
- const store = gstate({
23
- todos: [],
24
- user: null
25
- }, {
26
- namespace: 'myapp',
27
- sync: {
28
- endpoint: 'https://api.example.com/sync',
29
- // Use a getter function for secure token retrieval
30
- authToken: () => localStorage.getItem('auth_token'),
31
- autoSyncInterval: 30000, // Sync every 30s
32
- syncOnReconnect: true // Auto-sync when back online
33
- }
34
- })
35
-
36
- // Use in React components
37
- function TodoList() {
38
- const [todos, setTodos] = useSyncedState('todos')
39
-
40
- // Add todo - automatically queued for sync
41
- const addTodo = (text) => {
42
- setTodos([...todos, { id: Date.now(), text }])
43
- }
44
-
45
- return <div>{/* ... */}</div>
46
- }
47
- ```
48
-
49
- ## Configuration Options
50
-
51
- | Option | Type | Default | Description |
52
- |--------|------|---------|-------------|
53
- | `endpoint` | `string` | required | Remote sync server URL |
54
- | `authToken` | `string` or `() => string \| null` | - | Authentication token or getter function for secure retrieval |
55
- | `strategy` | `string` | `'last-write-wins'` | Conflict resolution |
56
- | `autoSyncInterval` | `number` | `30000` | Auto-sync interval (ms) |
57
- | `syncOnReconnect` | `boolean` | `true` | Sync on network restore |
58
- | `debounceTime` | `number` | `1000` | Batch changes (ms) |
59
- | `maxRetries` | `number` | `3` | Failed sync retries |
60
- | `onConflict` | `function` | - | Custom conflict handler |
61
- | `onSync` | `function` | - | Sync completion callback |
62
-
63
- ## Conflict Resolution Strategies
64
-
65
- ### 1. Last-Write-Wins (Default)
66
-
67
- ```typescript
68
- sync: { strategy: 'last-write-wins' }
69
- ```
70
- Latest timestamp wins - simplest strategy.
71
-
72
- ### 2. Server-Wins
73
-
74
- ```typescript
75
- sync: { strategy: 'server-wins' }
76
- ```
77
- Always prefer remote values - useful for read-heavy apps.
78
-
79
- ### 3. Client-Wins
80
-
81
- ```typescript
82
- sync: { strategy: 'client-wins' }
83
- ```
84
- Always prefer local values - useful for write-heavy apps.
85
-
86
- ### 4. Custom Merge
87
-
88
- ```typescript
89
- sync: {
90
- strategy: 'merge',
91
- onConflict: (conflict) => {
92
- // Custom logic for merging
93
- return {
94
- action: 'merge',
95
- value: { /* merged result */ }
96
- }
97
- }
98
- }
99
- ```
100
-
101
- ## Hook API
102
-
103
- ### useSyncedState
104
-
105
- ```typescript
106
- const [value, setValue, syncState] = useSyncedState('key')
107
-
108
- // syncState contains:
109
- // - isOnline: boolean
110
- // - isSyncing: boolean
111
- // - pendingChanges: number
112
- // - conflicts: number
113
- ```
114
-
115
- ### useSyncStatus
116
-
117
- ```typescript
118
- const status = useSyncStatus()
119
- // Global sync status across all stores
120
- ```
121
-
122
- ## Manual Sync Control
123
-
124
- ```typescript
125
- // Force sync
126
- await store.plugins.sync.flush()
127
-
128
- // Get sync state
129
- const state = store.plugins.sync.getState()
130
- ```
131
-
132
- ## Integration with Persistence
133
-
134
- The Sync Engine works seamlessly with RGS's existing persistence layer:
135
-
136
- - **Local Storage** - Data persists locally first
137
- - **IndexedDB** - For larger datasets
138
- - **Cloud Sync** - Optional remote backup
139
-
140
- Your data survives browser refresh, works offline, and stays synchronized across devices.
141
-
142
- ## Next Steps
143
-
144
- - Learn about [Security Architecture](09-security-architecture.md)
145
- - Explore [Plugin SDK](05-plugin-sdk.md)
146
- - Check [Migration Guide](08-migration-guide.md)
1
+ # 🚀 Chapter 10: Local-First Sync Engine
2
+
3
+ RGS now includes a powerful **Local-First Sync Engine** that makes your app work offline by default and automatically synchronize when connectivity is restored.
4
+
5
+ ## Why Local-First?
6
+
7
+ Traditional apps require an internet connection to work. Local-First apps work immediately with local data and sync in the background when possible.
8
+
9
+ ### Benefits
10
+
11
+ - **Instant Load** - No waiting for server responses
12
+ - **Works Offline** - App functions without internet
13
+ - **Better UX** - No loading spinners for data
14
+ - **Conflict Resolution** - Smart merge strategies
15
+
16
+ ## Quick Start
17
+
18
+ ```typescript
19
+ import { gstate, useSyncedState } from '@biglogic/rgs'
20
+
21
+ // Create store with sync enabled
22
+ const store = gstate({
23
+ todos: [],
24
+ user: null
25
+ }, {
26
+ namespace: 'myapp',
27
+ sync: {
28
+ endpoint: 'https://api.example.com/sync',
29
+ // Use a getter function for secure token retrieval
30
+ authToken: () => localStorage.getItem('auth_token'),
31
+ autoSyncInterval: 30000, // Sync every 30s
32
+ syncOnReconnect: true // Auto-sync when back online
33
+ }
34
+ })
35
+
36
+ // Use in React components
37
+ function TodoList() {
38
+ const [todos, setTodos] = useSyncedState('todos')
39
+
40
+ // Add todo - automatically queued for sync
41
+ const addTodo = (text) => {
42
+ setTodos([...todos, { id: Date.now(), text }])
43
+ }
44
+
45
+ return <div>{/* ... */}</div>
46
+ }
47
+ ```
48
+
49
+ ## Configuration Options
50
+
51
+ | Option | Type | Default | Description |
52
+ |--------|------|---------|-------------|
53
+ | `endpoint` | `string` | required | Remote sync server URL |
54
+ | `authToken` | `string` or `() => string \| null` | - | Authentication token or getter function for secure retrieval |
55
+ | `strategy` | `string` | `'last-write-wins'` | Conflict resolution |
56
+ | `autoSyncInterval` | `number` | `30000` | Auto-sync interval (ms) |
57
+ | `syncOnReconnect` | `boolean` | `true` | Sync on network restore |
58
+ | `debounceTime` | `number` | `1000` | Batch changes (ms) |
59
+ | `maxRetries` | `number` | `3` | Failed sync retries |
60
+ | `onConflict` | `function` | - | Custom conflict handler |
61
+ | `onSync` | `function` | - | Sync completion callback |
62
+
63
+ ## Conflict Resolution Strategies
64
+
65
+ ### 1. Last-Write-Wins (Default)
66
+
67
+ ```typescript
68
+ sync: { strategy: 'last-write-wins' }
69
+ ```
70
+ Latest timestamp wins - simplest strategy.
71
+
72
+ ### 2. Server-Wins
73
+
74
+ ```typescript
75
+ sync: { strategy: 'server-wins' }
76
+ ```
77
+ Always prefer remote values - useful for read-heavy apps.
78
+
79
+ ### 3. Client-Wins
80
+
81
+ ```typescript
82
+ sync: { strategy: 'client-wins' }
83
+ ```
84
+ Always prefer local values - useful for write-heavy apps.
85
+
86
+ ### 4. Custom Merge
87
+
88
+ ```typescript
89
+ sync: {
90
+ strategy: 'merge',
91
+ onConflict: (conflict) => {
92
+ // Custom logic for merging
93
+ return {
94
+ action: 'merge',
95
+ value: { /* merged result */ }
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ ## Hook API
102
+
103
+ ### useSyncedState
104
+
105
+ ```typescript
106
+ const [value, setValue, syncState] = useSyncedState('key')
107
+
108
+ // syncState contains:
109
+ // - isOnline: boolean
110
+ // - isSyncing: boolean
111
+ // - pendingChanges: number
112
+ // - conflicts: number
113
+ ```
114
+
115
+ ### useSyncStatus
116
+
117
+ ```typescript
118
+ const status = useSyncStatus()
119
+ // Global sync status across all stores
120
+ ```
121
+
122
+ ## Manual Sync Control
123
+
124
+ ```typescript
125
+ // Force sync
126
+ await store.plugins.sync.flush()
127
+
128
+ // Get sync state
129
+ const state = store.plugins.sync.getState()
130
+ ```
131
+
132
+ ## Integration with Persistence
133
+
134
+ The Sync Engine works seamlessly with RGS's existing persistence layer:
135
+
136
+ - **Local Storage** - Data persists locally first
137
+ - **IndexedDB** - For larger datasets
138
+ - **Cloud Sync** - Optional remote backup
139
+
140
+ Your data survives browser refresh, works offline, and stays synchronized across devices.
141
+
142
+ ## Next Steps
143
+
144
+ - Learn about [Security Architecture](09-security-architecture.md)
145
+ - Explore [Plugin SDK](05-plugin-sdk.md)
146
+ - Check [Migration Guide](08-migration-guide.md)
package/docs/qa.md CHANGED
@@ -1,47 +1,47 @@
1
- # 🚀 QA Release Checklist: Massive Change
2
-
3
- > **Release ID:** [Insert ID]
4
- > **Date:** 2026-02-19
5
- > **QA Lead:** [Name]
6
-
7
- ---
8
-
9
- ### 1. 🔍 Impact Analysis & Setup
10
- - [ ] **Traceability Matrix:** Mapping new requirements to existing test cases.
11
- - [ ] **Impact Analysis:** Identifying "High-Risk" modules (e.g., DB, API, Payment Gateway).
12
- - [ ] **Staging Environment:** Verify alignment of config/data with Production.
13
- - [ ] **Smoke Test Suite:** Selection of 10-15 fundamental tests to validate build stability.
14
-
15
- ### 2. 🛡️ Regression & Functional Testing
16
- - [ ] **Critical Regression:** Execution of automated tests on core flows (Business Critical).
17
- - [ ] **New Features:** Detailed validation according to acceptance criteria (AC).
18
- - [ ] **Edge Cases:** Testing on invalid inputs and boundary scenarios.
19
- - [ ] **Compatibility:** Testing on Browsers (Chrome, Safari, Firefox) and Mobile (iOS, Android).
20
-
21
- ### 3. ⚙️ Technical Integrity & Performance
22
- - [ ] **Data Migration:** Verify that DB changes haven't corrupted existing records.
23
- - [ ] **API Contracts:** Verify that endpoints haven't introduced breaking changes.
24
- - [ ] **Performance Baseline:** Check response times compared to the previous version.
25
- - [ ] **Security Scan:** Basic check on permissions and OWASP vulnerabilities.
26
-
27
- ### 4. 🏁 Release Readiness (Go/No-Go)
28
- - [ ] **UAT Sign-off:** Final approval from stakeholders.
29
- - [ ] **Rollback Plan:** Documented and ready recovery procedure.
30
- - [ ] **Feature Flags:** Verify that toggles are correctly configured on [LaunchDarkly](https://launchdarkly.com) or similar.
31
- - [ ] **Monitoring:** [Sentry](https://sentry.io) or [Datadog](https://www.datadoghq.com) dashboards ready for post-live monitoring.
32
-
33
- ---
34
-
35
- ### 📊 Execution Report
36
-
37
-
38
- | Category | Total Tests | Passed | Failed | Blockers |
39
- | :--- | :---: | :---: | :---: | :---: |
40
- | **Smoke Test** | 0 | 0 | 0 | 0 |
41
- | **Regression** | 0 | 0 | 0 | 0 |
42
- | **New Features**| 0 | 0 | 0 | 0 |
43
-
44
- ---
45
-
46
- **Final Notes:**
47
- *Add any critical bugs found or observations on stability here.*
1
+ # 🚀 QA Release Checklist: Massive Change
2
+
3
+ > **Release ID:** [Insert ID]
4
+ > **Date:** 2026-02-19
5
+ > **QA Lead:** [Name]
6
+
7
+ ---
8
+
9
+ ### 1. 🔍 Impact Analysis & Setup
10
+ - [ ] **Traceability Matrix:** Mapping new requirements to existing test cases.
11
+ - [ ] **Impact Analysis:** Identifying "High-Risk" modules (e.g., DB, API, Payment Gateway).
12
+ - [ ] **Staging Environment:** Verify alignment of config/data with Production.
13
+ - [ ] **Smoke Test Suite:** Selection of 10-15 fundamental tests to validate build stability.
14
+
15
+ ### 2. 🛡️ Regression & Functional Testing
16
+ - [ ] **Critical Regression:** Execution of automated tests on core flows (Business Critical).
17
+ - [ ] **New Features:** Detailed validation according to acceptance criteria (AC).
18
+ - [ ] **Edge Cases:** Testing on invalid inputs and boundary scenarios.
19
+ - [ ] **Compatibility:** Testing on Browsers (Chrome, Safari, Firefox) and Mobile (iOS, Android).
20
+
21
+ ### 3. ⚙️ Technical Integrity & Performance
22
+ - [ ] **Data Migration:** Verify that DB changes haven't corrupted existing records.
23
+ - [ ] **API Contracts:** Verify that endpoints haven't introduced breaking changes.
24
+ - [ ] **Performance Baseline:** Check response times compared to the previous version.
25
+ - [ ] **Security Scan:** Basic check on permissions and OWASP vulnerabilities.
26
+
27
+ ### 4. 🏁 Release Readiness (Go/No-Go)
28
+ - [ ] **UAT Sign-off:** Final approval from stakeholders.
29
+ - [ ] **Rollback Plan:** Documented and ready recovery procedure.
30
+ - [ ] **Feature Flags:** Verify that toggles are correctly configured on [LaunchDarkly](https://launchdarkly.com) or similar.
31
+ - [ ] **Monitoring:** [Sentry](https://sentry.io) or [Datadog](https://www.datadoghq.com) dashboards ready for post-live monitoring.
32
+
33
+ ---
34
+
35
+ ### 📊 Execution Report
36
+
37
+
38
+ | Category | Total Tests | Passed | Failed | Blockers |
39
+ | :--- | :---: | :---: | :---: | :---: |
40
+ | **Smoke Test** | 0 | 0 | 0 | 0 |
41
+ | **Regression** | 0 | 0 | 0 | 0 |
42
+ | **New Features**| 0 | 0 | 0 | 0 |
43
+
44
+ ---
45
+
46
+ **Final Notes:**
47
+ *Add any critical bugs found or observations on stability here.*
package/package.json CHANGED
@@ -1,74 +1,91 @@
1
- {
2
- "name": "@biglogic/rgs",
3
- "version": "3.7.6",
4
- "description": "Argis (RGS) - Reactive Global State: A react state everywhere made easy",
5
- "type": "module",
6
- "keywords": [
7
- "rgs",
8
- "gstate",
9
- "state-management",
10
- "react",
11
- "enterprise",
12
- "hooks",
13
- "global-state",
14
- "immer",
15
- "biglogic",
16
- "persistence",
17
- "react-globo-state",
18
- "argis"
19
- ],
20
- "homepage": "https://github.com/BigLogic-ca/rgs",
21
- "bugs": {
22
- "url": "https://github.com/BigLogic-ca/rgs/issues"
23
- },
24
- "license": "MIT",
25
- "author": "Dario Passariello <dariopassariello@gmail.com>",
26
- "contributors": [
27
- {
28
- "name": "Dario Passariello",
29
- "email": "dariopassariello@gmail.com",
30
- "url": "https://dario.passariello.ca/"
31
- },
32
- {
33
- "name": "Valeria Cala Scaglitta",
34
- "email": "valeriacalascaglitta@gmail.com"
35
- }
36
- ],
37
- "funding": {
38
- "type": "github",
39
- "url": "https://github.com/BigLogic-ca/rgs"
40
- },
41
- "repository": {
42
- "type": "git",
43
- "url": "git+https://github.com/BigLogic-ca/rgs.git"
44
- },
45
- "main": "./index.js",
46
- "types": "./index.d.ts",
47
- "engines": {
48
- "node": ">=16.0.0"
49
- },
50
- "scripts": {
51
- "dev": "npm run build:watch",
52
- "build": "node -e \"const fs=require('fs');if(fs.existsSync('./dist'))fs.rmSync('./dist',{recursive:true});\" && node ./esbuild.config.mjs && npx tsc -p tsconfig.json --emitDeclarationOnly",
53
- "build:watch": "node ./esbuild.config.mjs --watch",
54
- "build:extension": "cd vscode-extension && vsce package -o ../dist/rgs-extension.vsix",
55
- "npm:pack": "npm run build && cd dist && npm pack",
56
- "npm:publish": "npm run build && npm run build:extension && cd dist && npm publish --access=public",
57
- "lint": "cd tests && npm run lint",
58
- "tsc": "cd tests && tsc --noEmit",
59
- "test": "cd tests && npm test"
60
- },
61
- "devDependencies": {
62
- "@types/node": "^25.3.2",
63
- "@types/react": "^19.2.14",
64
- "@types/react-dom": "^19.2.3",
65
- "esbuild": "0.27.3",
66
- "esbuild-node-externals": "1.20.1",
67
- "esbuild-plugin-copy": "2.1.1",
68
- "immer": "11.1.4",
69
- "react": "^19.2.4",
70
- "react-dom": "^19.2.4",
71
- "tslib": "^2.8.1",
72
- "typescript": "^5.9.3"
73
- }
74
- }
1
+ {
2
+ "name": "@biglogic/rgs",
3
+ "version": "3.7.9",
4
+ "license": "MIT",
5
+ "description": "Argis (RGS) - Reactive Global State: A react state everywhere made easy",
6
+ "type": "module",
7
+ "main": "./index.js",
8
+ "types": "./index.d.ts",
9
+ "typings": "./types/*",
10
+ "homepage": "https://github.com/BigLogic-ca/rgs",
11
+ "engines": {
12
+ "node": ">=16.0.0"
13
+ },
14
+ "publishConfig": {
15
+ "access": "public",
16
+ "registry": "https://registry.npmjs.org/",
17
+ "provenance": true
18
+ },
19
+ "files": [
20
+ "**/*"
21
+ ],
22
+ "keywords": [
23
+ "rgs",
24
+ "gstate",
25
+ "state-management",
26
+ "react",
27
+ "enterprise",
28
+ "hooks",
29
+ "global-state",
30
+ "immer",
31
+ "biglogic",
32
+ "persistence",
33
+ "react-globo-state",
34
+ "argis"
35
+ ],
36
+ "copyright": "Dario Passariello",
37
+ "author": "Dario Passariello <dariopassariello@gmail.com>",
38
+ "contributors": [
39
+ {
40
+ "name": "Dario Passariello",
41
+ "email": "dariopassariello@gmail.com",
42
+ "url": "https://dario.passariello.ca/"
43
+ },
44
+ {
45
+ "name": "Valeria Cala Scaglitta",
46
+ "email": "valeriacalascaglitta@gmail.com"
47
+ }
48
+ ],
49
+ "funding": {
50
+ "type": "github",
51
+ "url": "https://github.com/BigLogic-ca/rgs"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "git+https://github.com/BigLogic-ca/rgs.git"
56
+ },
57
+ "bugs": {
58
+ "url": "https://github.com/BigLogic-ca/rgs/issues"
59
+ },
60
+ "support": {
61
+ "name": "Dario Passariello",
62
+ "url": "https://github.com/passariello/",
63
+ "email": "dariopassariello@gmail.com"
64
+ },
65
+ "scripts": {
66
+ "dev": "npm run build:watch",
67
+ "build": "node -e \"const fs=require('fs');if(fs.existsSync('./dist'))fs.rmSync('./dist',{recursive:true});\" && node ./esbuild.config.mjs && npx tsc -p tsconfig.json --emitDeclarationOnly",
68
+ "build:watch": "node ./esbuild.config.mjs --watch",
69
+ "build:extension": "cd vscode-extension && vsce package -o ../dist/rgs-extension.vsix",
70
+ "npm:pack": "npm run build && cd dist && npm pack",
71
+ "npm:publish": "npm run build && npm run build:extension && cd dist && npm publish --access=public",
72
+ "lint": "cd tests && npm run lint",
73
+ "tsc": "cd tests && tsc --noEmit",
74
+ "test": "cd tests && npm test"
75
+ },
76
+ "dependencies": {
77
+ "immer": "11.1.4"
78
+ },
79
+ "devDependencies": {
80
+ "@types/node": "^25.3.3",
81
+ "@types/react": "^19.2.14",
82
+ "@types/react-dom": "^19.2.3",
83
+ "esbuild": "0.27.3",
84
+ "esbuild-node-externals": "1.20.1",
85
+ "esbuild-plugin-copy": "2.1.1",
86
+ "react": "^19.2.4",
87
+ "react-dom": "^19.2.4",
88
+ "tslib": "^2.8.1",
89
+ "typescript": "^5.9.3"
90
+ }
91
+ }
Binary file