strata-storage 2.4.3 → 2.5.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/AI-INTEGRATION-GUIDE.md +115 -261
- package/README.md +426 -182
- package/android/AGENTS.md +34 -0
- package/android/CLAUDE.md +51 -0
- package/android/src/main/java/com/strata/storage/SQLiteStorage.java +35 -0
- package/android/src/main/java/com/stratastorage/StrataStoragePlugin.java +191 -27
- package/dist/README.md +426 -182
- package/dist/adapters/capacitor/FilesystemAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/FilesystemAdapter.js +2 -1
- package/dist/adapters/capacitor/PreferencesAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/PreferencesAdapter.js +2 -1
- package/dist/adapters/capacitor/SecureAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/SecureAdapter.js +2 -1
- package/dist/adapters/capacitor/SqliteAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/SqliteAdapter.js +2 -1
- package/dist/adapters/web/CacheAdapter.d.ts.map +1 -1
- package/dist/adapters/web/CacheAdapter.js +11 -3
- package/dist/adapters/web/CookieAdapter.d.ts +37 -1
- package/dist/adapters/web/CookieAdapter.d.ts.map +1 -1
- package/dist/adapters/web/CookieAdapter.js +89 -9
- package/dist/adapters/web/IndexedDBAdapter.d.ts.map +1 -1
- package/dist/adapters/web/IndexedDBAdapter.js +10 -2
- package/dist/adapters/web/LocalStorageAdapter.d.ts +31 -0
- package/dist/adapters/web/LocalStorageAdapter.d.ts.map +1 -1
- package/dist/adapters/web/LocalStorageAdapter.js +92 -19
- package/dist/adapters/web/MemoryAdapter.d.ts +24 -0
- package/dist/adapters/web/MemoryAdapter.d.ts.map +1 -1
- package/dist/adapters/web/MemoryAdapter.js +69 -18
- package/dist/adapters/web/SessionStorageAdapter.d.ts +24 -0
- package/dist/adapters/web/SessionStorageAdapter.d.ts.map +1 -1
- package/dist/adapters/web/SessionStorageAdapter.js +71 -9
- package/dist/adapters/web/URLAdapter.d.ts +59 -0
- package/dist/adapters/web/URLAdapter.d.ts.map +1 -0
- package/dist/adapters/web/URLAdapter.js +234 -0
- package/dist/adapters/web/index.d.ts +1 -0
- package/dist/adapters/web/index.d.ts.map +1 -1
- package/dist/adapters/web/index.js +1 -0
- package/dist/android/AGENTS.md +34 -0
- package/dist/android/CLAUDE.md +51 -0
- package/dist/android/src/main/java/com/strata/storage/SQLiteStorage.java +35 -0
- package/dist/android/src/main/java/com/stratastorage/StrataStoragePlugin.java +191 -27
- package/dist/capacitor.d.ts.map +1 -1
- package/dist/capacitor.js +2 -1
- package/dist/core/BaseAdapter.d.ts +8 -0
- package/dist/core/BaseAdapter.d.ts.map +1 -1
- package/dist/core/BaseAdapter.js +34 -14
- package/dist/core/Strata.d.ts +56 -2
- package/dist/core/Strata.d.ts.map +1 -1
- package/dist/core/Strata.js +501 -53
- package/dist/features/encryption.d.ts.map +1 -1
- package/dist/features/encryption.js +3 -2
- package/dist/features/integrity.d.ts +16 -0
- package/dist/features/integrity.d.ts.map +1 -0
- package/dist/features/integrity.js +28 -0
- package/dist/features/observer.d.ts.map +1 -1
- package/dist/features/observer.js +2 -1
- package/dist/features/query.d.ts +7 -1
- package/dist/features/query.d.ts.map +1 -1
- package/dist/features/query.js +9 -2
- package/dist/features/sync.d.ts.map +1 -1
- package/dist/features/sync.js +4 -3
- package/dist/index.d.ts +35 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +55 -30
- package/dist/integrations/angular/index.d.ts +158 -0
- package/dist/integrations/angular/index.d.ts.map +1 -0
- package/dist/integrations/angular/index.js +395 -0
- package/dist/integrations/index.d.ts +15 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +18 -0
- package/dist/integrations/react/index.d.ts +75 -0
- package/dist/integrations/react/index.d.ts.map +1 -0
- package/dist/integrations/react/index.js +191 -0
- package/dist/integrations/vue/index.d.ts +103 -0
- package/dist/integrations/vue/index.d.ts.map +1 -0
- package/dist/integrations/vue/index.js +274 -0
- package/dist/ios/AGENTS.md +33 -0
- package/dist/ios/CLAUDE.md +49 -0
- package/dist/ios/Plugin/KeychainStorage.swift +139 -50
- package/dist/ios/Plugin/SQLiteStorage.swift +40 -0
- package/dist/ios/Plugin/StrataStoragePlugin.m +23 -0
- package/dist/ios/Plugin/StrataStoragePlugin.swift +201 -52
- package/dist/package.json +21 -5
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +2 -1
- package/dist/types/index.d.ts +58 -9
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -13
- package/dist/utils/errors.d.ts +7 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +15 -3
- package/dist/utils/index.d.ts +63 -5
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +109 -16
- package/dist/utils/logger.d.ts +31 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +63 -0
- package/ios/AGENTS.md +33 -0
- package/ios/CLAUDE.md +49 -0
- package/ios/Plugin/KeychainStorage.swift +139 -50
- package/ios/Plugin/SQLiteStorage.swift +40 -0
- package/ios/Plugin/StrataStoragePlugin.m +23 -0
- package/ios/Plugin/StrataStoragePlugin.swift +201 -52
- package/package.json +31 -20
- package/scripts/build.js +16 -5
- package/scripts/configure.js +2 -6
- package/scripts/postinstall.js +2 -2
- package/Readme.md +0 -271
package/Readme.md
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
# Strata Storage
|
|
2
|
-
|
|
3
|
-
## 📚 Documentation
|
|
4
|
-
|
|
5
|
-
### Getting Started
|
|
6
|
-
- **[Installation](./docs/getting-started/installation.md)** - Installation and setup
|
|
7
|
-
- **[Quick Start Guide](./docs/getting-started/quick-start.md)** - Get running in minutes
|
|
8
|
-
- **[Configuration](./docs/getting-started/configuration.md)** - Configuration options
|
|
9
|
-
|
|
10
|
-
### Core Documentation
|
|
11
|
-
- **[API Reference](./docs/api/README.md)** - Complete API documentation
|
|
12
|
-
- **[Core API](./docs/api/core/strata.md)** - Main Strata class
|
|
13
|
-
- **[Type Definitions](./docs/api/core/types.md)** - TypeScript types
|
|
14
|
-
- **[Error Handling](./docs/api/core/errors.md)** - Error types and handling
|
|
15
|
-
|
|
16
|
-
### Storage Adapters
|
|
17
|
-
- **[Web Adapters](./docs/api/adapters/README.md#web-adapters)** - Browser storage
|
|
18
|
-
- [localStorage](./docs/api/adapters/web/localstorage.md)
|
|
19
|
-
- [sessionStorage](./docs/api/adapters/web/sessionstorage.md)
|
|
20
|
-
- [IndexedDB](./docs/api/adapters/web/indexeddb.md)
|
|
21
|
-
- [Cookies](./docs/api/adapters/web/cookies.md)
|
|
22
|
-
- [Cache API](./docs/api/adapters/web/cache.md)
|
|
23
|
-
- [Memory](./docs/api/adapters/web/memory.md)
|
|
24
|
-
- **[Capacitor Adapters](./docs/api/adapters/README.md#capacitor-adapters)** - Native storage
|
|
25
|
-
- [Preferences](./docs/api/adapters/capacitor/preferences.md)
|
|
26
|
-
- [Secure Storage](./docs/api/adapters/capacitor/secure.md)
|
|
27
|
-
- [SQLite](./docs/api/adapters/capacitor/sqlite.md)
|
|
28
|
-
- [Filesystem](./docs/api/adapters/capacitor/filesystem.md)
|
|
29
|
-
|
|
30
|
-
### Advanced Features
|
|
31
|
-
- **[Encryption](./docs/guides/features/encryption.md)** - Data encryption guide
|
|
32
|
-
- **[Compression](./docs/guides/features/compression.md)** - Data compression
|
|
33
|
-
- **[TTL Management](./docs/api/features/ttl.md)** - Auto-expiration
|
|
34
|
-
- **[Cross-Tab Sync](./docs/guides/features/sync.md)** - Real-time synchronization
|
|
35
|
-
- **[Query Engine](./docs/guides/features/queries.md)** - MongoDB-like queries
|
|
36
|
-
- **[Migrations](./docs/guides/features/migrations.md)** - Data migration system
|
|
37
|
-
|
|
38
|
-
### Platform Guides
|
|
39
|
-
- **[Web Platform](./docs/guides/platforms/web.md)** - Browser-specific features
|
|
40
|
-
- **[iOS Platform](./docs/guides/platforms/ios.md)** - iOS implementation
|
|
41
|
-
- **[Android Platform](./docs/guides/platforms/android.md)** - Android implementation
|
|
42
|
-
- **[Capacitor](./docs/guides/platforms/capacitor.md)** - Capacitor integration
|
|
43
|
-
|
|
44
|
-
### Common Patterns
|
|
45
|
-
- **[Caching Strategies](./docs/guides/patterns/caching.md)** - Caching best practices
|
|
46
|
-
- **[Session Management](./docs/guides/patterns/sessions.md)** - User session handling
|
|
47
|
-
|
|
48
|
-
### Examples
|
|
49
|
-
- **[Basic Usage](./docs/examples/basic-usage.md)** - Simple examples
|
|
50
|
-
- **[React Integration](./docs/examples/frameworks/react.md)** - React hooks and providers
|
|
51
|
-
- **[Vue Integration](./docs/examples/frameworks/vue.md)** - Vue composables
|
|
52
|
-
- **[Angular Integration](./docs/examples/frameworks/angular.md)** - Angular services
|
|
53
|
-
- **[Authentication](./docs/examples/user-auth.md)** - User authentication
|
|
54
|
-
- **[Shopping Cart](./docs/examples/shopping-cart.md)** - E-commerce example
|
|
55
|
-
- **[Form Persistence](./docs/examples/form-persistence.md)** - Form data saving
|
|
56
|
-
- **[Offline Support](./docs/examples/offline-support.md)** - Offline-first apps
|
|
57
|
-
- **[All Examples](./docs/examples/README.md)** - Complete examples list
|
|
58
|
-
|
|
59
|
-
### Resources
|
|
60
|
-
- **[GitHub](https://github.com/aoneahsan/strata-storage)** - Source code
|
|
61
|
-
- **[NPM](https://www.npmjs.com/package/strata-storage)** - Package registry
|
|
62
|
-
- **[Example App](./examples/react-capacitor-app)** - Full demo application
|
|
63
|
-
- **[Contributing](./.github/CONTRIBUTING.md)** - How to contribute
|
|
64
|
-
- **[Support](./.github/SUPPORT.md)** - Get help
|
|
65
|
-
- **[Security](./.github/SECURITY.md)** - Report vulnerabilities
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
**One API. Every Storage. Everywhere.**
|
|
70
|
-
|
|
71
|
-
Zero-dependency universal storage plugin providing a unified API for all storage operations across web, Android, and iOS platforms.
|
|
72
|
-
|
|
73
|
-
## 🚀 Quick Start
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
npm install strata-storage
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### Provider-less Usage (Zero Setup)
|
|
80
|
-
```typescript
|
|
81
|
-
import { storage } from 'strata-storage';
|
|
82
|
-
|
|
83
|
-
// Works immediately - no setup, no providers, no initialization!
|
|
84
|
-
await storage.set('user', { name: 'John', age: 30 });
|
|
85
|
-
const user = await storage.get('user');
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Complete Example App
|
|
89
|
-
|
|
90
|
-
Check out our [React + Capacitor example app](./examples/react-capacitor-app) that demonstrates all features:
|
|
91
|
-
- All storage adapters working correctly
|
|
92
|
-
- Web, Android, and iOS platform support
|
|
93
|
-
- Real-time testing interface
|
|
94
|
-
- Complete error handling
|
|
95
|
-
|
|
96
|
-
Run the example:
|
|
97
|
-
```bash
|
|
98
|
-
cd examples/react-capacitor-app
|
|
99
|
-
yarn install
|
|
100
|
-
yarn start # For web
|
|
101
|
-
npx cap run android # For Android
|
|
102
|
-
npx cap run ios # For iOS
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### With Capacitor (Optional)
|
|
106
|
-
```typescript
|
|
107
|
-
import { storage } from 'strata-storage';
|
|
108
|
-
import { registerCapacitorAdapters } from 'strata-storage/capacitor';
|
|
109
|
-
|
|
110
|
-
// Only if you need native features
|
|
111
|
-
if (window.Capacitor) {
|
|
112
|
-
await registerCapacitorAdapters(storage);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Use native storage when available
|
|
116
|
-
await storage.set('secure-data', 'secret', { storage: 'secure' });
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### With Firebase (Optional)
|
|
120
|
-
```typescript
|
|
121
|
-
import { storage } from 'strata-storage';
|
|
122
|
-
import { enableFirebaseSync } from 'strata-storage/firebase';
|
|
123
|
-
|
|
124
|
-
// Only if you need cloud sync
|
|
125
|
-
if (needCloudSync) {
|
|
126
|
-
await enableFirebaseSync(storage, {
|
|
127
|
-
apiKey: 'your-api-key',
|
|
128
|
-
projectId: 'your-project-id',
|
|
129
|
-
firestore: true
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Works offline-first, syncs when online
|
|
134
|
-
await storage.set('data', value, { storage: 'firestore' });
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
## ✨ Features
|
|
138
|
-
|
|
139
|
-
### Core Features
|
|
140
|
-
- ✅ **Zero Dependencies** - No runtime dependencies, pure implementation
|
|
141
|
-
- ✅ **Provider-less Architecture** - No providers, contexts, or wrappers needed (like zustand)
|
|
142
|
-
- ✅ **Works Everywhere** - React, Vue, Angular, Vanilla JS, Node.js - same API
|
|
143
|
-
- ✅ **Zero Configuration** - Import and use immediately, no setup required
|
|
144
|
-
- ✅ **Opt-in Complexity** - Start simple, add features only when needed
|
|
145
|
-
- ✅ **Dynamic Provider Loading** - Providers load only when used, keeping bundle small
|
|
146
|
-
- ✅ **Universal API** - Single interface for all storage types
|
|
147
|
-
- ✅ **Cross-Platform** - Web, iOS, Android support
|
|
148
|
-
- ✅ **TypeScript** - Full type safety and IntelliSense
|
|
149
|
-
- ✅ **Auto Fallback** - Intelligent storage selection
|
|
150
|
-
|
|
151
|
-
### Storage Adapters
|
|
152
|
-
- ✅ **Memory** - Fast in-memory storage
|
|
153
|
-
- ✅ **LocalStorage** - Persistent browser storage
|
|
154
|
-
- ✅ **SessionStorage** - Session-based browser storage
|
|
155
|
-
- ✅ **IndexedDB** - Large-scale browser database
|
|
156
|
-
- ✅ **Cookies** - HTTP cookie storage
|
|
157
|
-
- ✅ **Cache API** - Service worker cache storage
|
|
158
|
-
- ✅ **Capacitor Preferences** - Native mobile preferences
|
|
159
|
-
- ✅ **SQLite** - Mobile SQL database
|
|
160
|
-
- ✅ **Secure Storage** - Keychain (iOS) / Encrypted SharedPreferences (Android)
|
|
161
|
-
- ✅ **Filesystem** - File-based storage
|
|
162
|
-
|
|
163
|
-
### Advanced Features
|
|
164
|
-
- ✅ **[Encryption](./docs/guides/features/encryption.md)** - AES-GCM encryption with Web Crypto API
|
|
165
|
-
- ✅ **[Compression](./docs/guides/features/compression.md)** - LZ-string compression algorithm
|
|
166
|
-
- ✅ **[Cross-Tab Sync](./docs/guides/features/sync.md)** - Real-time synchronization across tabs
|
|
167
|
-
- ✅ **[Query Engine](./docs/guides/features/queries.md)** - MongoDB-like queries for filtering data
|
|
168
|
-
- ✅ **[TTL Support](./docs/api/features/ttl.md)** - Automatic expiration with sliding TTL
|
|
169
|
-
- ✅ **[Migration System](./docs/guides/features/migrations.md)** - Version-based data migrations
|
|
170
|
-
- ✅ **Framework Integrations** - [React](./docs/examples/frameworks/react.md), [Vue](./docs/examples/frameworks/vue.md), [Angular](./docs/examples/frameworks/angular.md)
|
|
171
|
-
|
|
172
|
-
## 📖 Basic Usage
|
|
173
|
-
|
|
174
|
-
```typescript
|
|
175
|
-
import { storage } from 'strata-storage';
|
|
176
|
-
|
|
177
|
-
// No initialization needed - works immediately!
|
|
178
|
-
|
|
179
|
-
// Simple usage
|
|
180
|
-
await storage.set('key', 'value');
|
|
181
|
-
const value = await storage.get('key');
|
|
182
|
-
await storage.remove('key');
|
|
183
|
-
await storage.clear();
|
|
184
|
-
|
|
185
|
-
// Advanced options
|
|
186
|
-
await storage.set('key', value, {
|
|
187
|
-
storage: 'indexedDB', // Choose specific storage
|
|
188
|
-
ttl: 3600000, // Expire in 1 hour
|
|
189
|
-
encrypt: true, // Encrypt this value
|
|
190
|
-
compress: true, // Compress if beneficial
|
|
191
|
-
tags: ['user-data'], // Tag for grouping
|
|
192
|
-
metadata: { // Attach metadata
|
|
193
|
-
version: 1,
|
|
194
|
-
source: 'api'
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
// Query data with MongoDB-like syntax
|
|
199
|
-
const results = await storage.query({
|
|
200
|
-
tags: { $in: ['user-data'] },
|
|
201
|
-
'value.age': { $gte: 18 },
|
|
202
|
-
'metadata.version': 1
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
// Subscribe to changes
|
|
206
|
-
storage.subscribe((change) => {
|
|
207
|
-
console.log(`${change.key} changed from ${change.oldValue} to ${change.newValue}`);
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
// Check storage size
|
|
211
|
-
const size = await storage.size();
|
|
212
|
-
console.log(`Using ${size.total} bytes for ${size.count} items`);
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
## 🎯 Why Strata Storage?
|
|
216
|
-
|
|
217
|
-
### Provider-less Architecture
|
|
218
|
-
Like Zustand, Strata Storage works without providers, contexts, or wrappers. Just import and use - no setup required.
|
|
219
|
-
|
|
220
|
-
### Zero Dependencies
|
|
221
|
-
Truly zero runtime dependencies. Everything is implemented from scratch for maximum control and minimal bundle size.
|
|
222
|
-
|
|
223
|
-
### Universal Compatibility
|
|
224
|
-
- **One API** - Same code works on Web, iOS, and Android
|
|
225
|
-
- **Any Framework** - Works with React, Vue, Angular, or vanilla JavaScript
|
|
226
|
-
- **TypeScript First** - Full type safety and excellent IntelliSense
|
|
227
|
-
- **Tree-Shakeable** - Only bundle what you use
|
|
228
|
-
|
|
229
|
-
### Intelligent Storage Selection
|
|
230
|
-
Automatically selects the best available storage based on:
|
|
231
|
-
- Platform capabilities
|
|
232
|
-
- Data size and type
|
|
233
|
-
- Performance requirements
|
|
234
|
-
- Persistence needs
|
|
235
|
-
|
|
236
|
-
### Enterprise Ready
|
|
237
|
-
- **Encryption** - Built-in AES-GCM encryption
|
|
238
|
-
- **Compression** - Automatic data compression
|
|
239
|
-
- **TTL/Expiration** - Auto-cleanup of expired data
|
|
240
|
-
- **Sync** - Real-time cross-tab/device synchronization
|
|
241
|
-
- **Migrations** - Version-based data migrations
|
|
242
|
-
- **Querying** - MongoDB-like query engine
|
|
243
|
-
|
|
244
|
-
## 🏗 Project Status
|
|
245
|
-
|
|
246
|
-
**Production Ready** - All major features implemented:
|
|
247
|
-
- ✅ Zero-dependency architecture
|
|
248
|
-
- ✅ Provider-less design (like Zustand)
|
|
249
|
-
- ✅ All web storage adapters (localStorage, IndexedDB, etc.)
|
|
250
|
-
- ✅ Complete Capacitor integration (iOS/Android)
|
|
251
|
-
- ✅ Native implementations (iOS Swift, Android Java)
|
|
252
|
-
- ✅ Advanced features (encryption, compression, sync, query, TTL)
|
|
253
|
-
- ✅ Framework integrations (React, Vue, Angular)
|
|
254
|
-
- ✅ Comprehensive documentation
|
|
255
|
-
- ✅ Full TypeScript support
|
|
256
|
-
- ✅ Example application with all features
|
|
257
|
-
|
|
258
|
-
## 📄 License
|
|
259
|
-
|
|
260
|
-
**Apache 2.0** - See [LICENSE](./LICENSE) and [License Details](./docs/LICENSE.md)
|
|
261
|
-
|
|
262
|
-
### Quick Summary:
|
|
263
|
-
- ✅ **Free for commercial use**
|
|
264
|
-
- ✅ **Modify and distribute**
|
|
265
|
-
- ✅ **Patent protection included**
|
|
266
|
-
- ⚠️ **Must keep attribution**
|
|
267
|
-
- ❌ **No warranty provided**
|
|
268
|
-
|
|
269
|
-
---
|
|
270
|
-
|
|
271
|
-
Created by Ahsan Mahmood
|