async-storage-sync 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -135,6 +135,19 @@ initSyncQueue({
|
|
|
135
135
|
});
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
+
**Use custom auth headers/keys:**
|
|
139
|
+
```ts
|
|
140
|
+
initSyncQueue({
|
|
141
|
+
driver: 'asyncstorage',
|
|
142
|
+
serverUrl: 'https://api.example.com',
|
|
143
|
+
credentials: {
|
|
144
|
+
Authorization: 'Token abc123',
|
|
145
|
+
'x-api-key': 'my-custom-key',
|
|
146
|
+
},
|
|
147
|
+
endpoint: '/submit',
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
138
151
|
**Handle duplicates:**
|
|
139
152
|
```ts
|
|
140
153
|
// Keep all (default)
|
|
@@ -159,7 +172,7 @@ await store.deleteCollection('submissions');
|
|
|
159
172
|
initSyncQueue({
|
|
160
173
|
driver: 'asyncstorage', // (required) only driver type
|
|
161
174
|
serverUrl: string, // (required) API base URL
|
|
162
|
-
credentials:
|
|
175
|
+
credentials: Record<string, string>, // (required) merged into request headers
|
|
163
176
|
endpoint?: '/submit', // route to POST data
|
|
164
177
|
autoSync?: false, // auto-sync on reconnect
|
|
165
178
|
onSyncSuccess?: 'keep', // after sync: keep|delete|ttl
|
|
@@ -169,6 +182,10 @@ initSyncQueue({
|
|
|
169
182
|
});
|
|
170
183
|
```
|
|
171
184
|
|
|
185
|
+
Notes:
|
|
186
|
+
- `credentials.apiKey` remains supported and is sent as `Authorization: Bearer <apiKey>` if no `Authorization` header is provided.
|
|
187
|
+
- Any other key/value pairs in `credentials` are sent as-is in request headers.
|
|
188
|
+
|
|
172
189
|
## How It Works
|
|
173
190
|
|
|
174
191
|
1. **Save** — Records written to AsyncStorage immediately
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "async-storage-sync",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Offline-first data layer for React Native with local-first storage and automatic sync",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@react-native-async-storage/async-storage": ">=1.0.0",
|
|
26
|
-
"@react-native-community/netinfo": "
|
|
26
|
+
"@react-native-community/netinfo": ">=11",
|
|
27
27
|
"react-native": ">=0.70.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|