strata-storage 2.6.1 → 2.7.1
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 +129 -11
- package/README.md +42 -64
- package/android/AGENTS.md +18 -3
- package/android/CLAUDE.md +36 -3
- package/android/build.gradle +5 -1
- package/android/src/main/java/com/strata/storage/EncryptedStorage.java +31 -18
- package/android/src/main/java/com/strata/storage/FilesystemStorage.java +62 -10
- package/android/src/main/java/com/strata/storage/SQLiteStorage.java +65 -13
- package/android/src/main/java/com/strata/storage/SharedPreferencesStorage.java +63 -51
- package/android/src/main/java/com/stratastorage/StrataStoragePlugin.java +80 -11
- package/dist/README.md +42 -64
- package/dist/adapters/capacitor/FilesystemAdapter.d.ts +2 -2
- package/dist/adapters/capacitor/FilesystemAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/FilesystemAdapter.js +6 -2
- package/dist/adapters/capacitor/PreferencesAdapter.d.ts +2 -2
- package/dist/adapters/capacitor/PreferencesAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/PreferencesAdapter.js +6 -2
- package/dist/adapters/capacitor/SecureAdapter.d.ts +3 -3
- package/dist/adapters/capacitor/SecureAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/SecureAdapter.js +6 -2
- package/dist/adapters/capacitor/SqliteAdapter.d.ts +24 -3
- package/dist/adapters/capacitor/SqliteAdapter.d.ts.map +1 -1
- package/dist/adapters/capacitor/SqliteAdapter.js +105 -23
- package/dist/adapters/capacitor/index.d.ts +4 -4
- package/dist/adapters/web/CacheAdapter.d.ts +2 -2
- package/dist/adapters/web/CacheAdapter.d.ts.map +1 -1
- package/dist/adapters/web/CacheAdapter.js +20 -5
- package/dist/adapters/web/CookieAdapter.d.ts +2 -2
- package/dist/adapters/web/CookieAdapter.d.ts.map +1 -1
- package/dist/adapters/web/CookieAdapter.js +27 -3
- package/dist/adapters/web/IndexedDBAdapter.d.ts +10 -3
- package/dist/adapters/web/IndexedDBAdapter.d.ts.map +1 -1
- package/dist/adapters/web/IndexedDBAdapter.js +19 -4
- package/dist/adapters/web/LocalStorageAdapter.d.ts +2 -2
- package/dist/adapters/web/LocalStorageAdapter.d.ts.map +1 -1
- package/dist/adapters/web/LocalStorageAdapter.js +15 -1
- package/dist/adapters/web/MemoryAdapter.d.ts +9 -2
- package/dist/adapters/web/MemoryAdapter.d.ts.map +1 -1
- package/dist/adapters/web/MemoryAdapter.js +22 -5
- package/dist/adapters/web/SessionStorageAdapter.d.ts +10 -10
- package/dist/adapters/web/SessionStorageAdapter.d.ts.map +1 -1
- package/dist/adapters/web/SessionStorageAdapter.js +17 -3
- package/dist/adapters/web/URLAdapter.d.ts +2 -2
- package/dist/adapters/web/index.d.ts +7 -7
- package/dist/capacitor.d.ts +6 -6
- package/dist/capacitor.d.ts.map +1 -1
- package/dist/capacitor.js +5 -4
- package/dist/core/AdapterRegistry.d.ts +1 -1
- package/dist/core/BaseAdapter.d.ts +21 -5
- package/dist/core/BaseAdapter.d.ts.map +1 -1
- package/dist/core/BaseAdapter.js +29 -1
- package/dist/core/Strata.d.ts +53 -7
- package/dist/core/Strata.d.ts.map +1 -1
- package/dist/core/Strata.js +581 -125
- package/dist/features/compression/index.d.ts +1 -1
- package/dist/features/compression.d.ts +28 -9
- package/dist/features/compression.d.ts.map +1 -1
- package/dist/features/compression.js +164 -77
- package/dist/features/encryption/index.d.ts +1 -1
- package/dist/features/encryption.d.ts +55 -2
- package/dist/features/encryption.d.ts.map +1 -1
- package/dist/features/encryption.js +139 -26
- package/dist/features/migration.d.ts +1 -1
- package/dist/features/migration.d.ts.map +1 -1
- package/dist/features/migration.js +7 -2
- package/dist/features/observer/index.d.ts +1 -1
- package/dist/features/observer.d.ts +1 -1
- package/dist/features/query/index.d.ts +1 -1
- package/dist/features/query.d.ts +2 -1
- package/dist/features/query.d.ts.map +1 -1
- package/dist/features/query.js +32 -7
- package/dist/features/sync/index.d.ts +1 -1
- package/dist/features/sync.d.ts +19 -3
- package/dist/features/sync.d.ts.map +1 -1
- package/dist/features/sync.js +75 -12
- package/dist/features/ttl/index.d.ts +1 -1
- package/dist/features/ttl.d.ts +2 -2
- package/dist/features/ttl.d.ts.map +1 -1
- package/dist/features/ttl.js +4 -2
- package/dist/firebase.d.ts +1 -1
- package/dist/firebase.d.ts.map +1 -1
- package/dist/firebase.js +72 -10
- package/dist/index.d.ts +24 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/integrations/angular/index.d.ts +2 -2
- package/dist/integrations/angular/index.d.ts.map +1 -1
- package/dist/integrations/angular/index.js +7 -8
- package/dist/integrations/react/index.d.ts +3 -3
- package/dist/integrations/react/index.d.ts.map +1 -1
- package/dist/integrations/react/index.js +16 -4
- package/dist/integrations/vue/index.d.ts +2 -2
- package/dist/integrations/vue/index.d.ts.map +1 -1
- package/dist/integrations/vue/index.js +5 -2
- package/dist/package.json +11 -2
- package/dist/plugin/definitions.d.ts +29 -3
- package/dist/plugin/definitions.d.ts.map +1 -1
- package/dist/plugin/index.d.ts +2 -2
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +3 -0
- package/dist/plugin/web.d.ts +11 -2
- package/dist/plugin/web.d.ts.map +1 -1
- package/dist/plugin/web.js +23 -4
- package/dist/types/index.d.ts +50 -20
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -10
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +7 -0
- package/ios/AGENTS.md +14 -3
- package/ios/CLAUDE.md +25 -3
- package/ios/Plugin/FilesystemStorage.swift +19 -0
- package/ios/Plugin/SQLiteStorage.swift +59 -9
- package/ios/Plugin/StrataStoragePlugin.m +1 -0
- package/ios/Plugin/StrataStoragePlugin.swift +87 -34
- package/ios/Plugin/UserDefaultsStorage.swift +47 -46
- package/package.json +27 -24
- package/scripts/build.js +46 -27
- package/scripts/cli.js +1 -1
- package/scripts/configure.js +2 -2
- package/scripts/postinstall.js +3 -2
- package/dist/android/AGENTS.md +0 -51
- package/dist/android/CLAUDE.md +0 -89
- package/dist/android/build.gradle +0 -58
- package/dist/android/proguard-rules.pro +0 -11
- package/dist/android/settings.gradle +0 -2
- package/dist/android/src/main/AndroidManifest.xml +0 -2
- package/dist/android/src/main/java/com/strata/storage/EncryptedStorage.java +0 -218
- package/dist/android/src/main/java/com/strata/storage/FilesystemStorage.java +0 -287
- package/dist/android/src/main/java/com/strata/storage/SQLiteStorage.java +0 -371
- package/dist/android/src/main/java/com/strata/storage/SharedPreferencesStorage.java +0 -209
- package/dist/android/src/main/java/com/stratastorage/StrataStoragePlugin.java +0 -616
- package/dist/core/StorageStrategy.d.ts +0 -55
- package/dist/core/StorageStrategy.d.ts.map +0 -1
- package/dist/core/StorageStrategy.js +0 -200
- package/dist/ios/AGENTS.md +0 -48
- package/dist/ios/CLAUDE.md +0 -84
- package/dist/ios/Plugin/FilesystemStorage.swift +0 -218
- package/dist/ios/Plugin/KeychainStorage.swift +0 -233
- package/dist/ios/Plugin/SQLiteStorage.swift +0 -426
- package/dist/ios/Plugin/StrataStoragePlugin.m +0 -23
- package/dist/ios/Plugin/StrataStoragePlugin.swift +0 -411
- package/dist/ios/Plugin/UserDefaultsStorage.swift +0 -87
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
package com.strata.storage;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
import android.content.SharedPreferences;
|
|
5
|
-
import android.util.Log;
|
|
6
|
-
import java.util.Map;
|
|
7
|
-
import java.util.Set;
|
|
8
|
-
import java.util.HashSet;
|
|
9
|
-
import java.util.List;
|
|
10
|
-
import java.util.ArrayList;
|
|
11
|
-
import org.json.JSONObject;
|
|
12
|
-
import org.json.JSONArray;
|
|
13
|
-
|
|
14
|
-
public class SharedPreferencesStorage {
|
|
15
|
-
private final SharedPreferences prefs;
|
|
16
|
-
private final SharedPreferences.Editor editor;
|
|
17
|
-
private static final String DEFAULT_NAME = "StrataStorage";
|
|
18
|
-
|
|
19
|
-
public SharedPreferencesStorage(Context context) {
|
|
20
|
-
this(context, DEFAULT_NAME);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
public SharedPreferencesStorage(Context context, String name) {
|
|
24
|
-
this.prefs = context.getSharedPreferences(name != null ? name : DEFAULT_NAME, Context.MODE_PRIVATE);
|
|
25
|
-
this.editor = prefs.edit();
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
public boolean set(String key, Object value) {
|
|
29
|
-
try {
|
|
30
|
-
if (value instanceof String) {
|
|
31
|
-
editor.putString(key, (String) value);
|
|
32
|
-
} else if (value instanceof Integer) {
|
|
33
|
-
editor.putInt(key, (Integer) value);
|
|
34
|
-
} else if (value instanceof Long) {
|
|
35
|
-
editor.putLong(key, (Long) value);
|
|
36
|
-
} else if (value instanceof Float) {
|
|
37
|
-
editor.putFloat(key, (Float) value);
|
|
38
|
-
} else if (value instanceof Boolean) {
|
|
39
|
-
editor.putBoolean(key, (Boolean) value);
|
|
40
|
-
} else if (value instanceof Set) {
|
|
41
|
-
// Safely convert to Set<String>
|
|
42
|
-
Set<?> rawSet = (Set<?>) value;
|
|
43
|
-
Set<String> stringSet = new HashSet<>();
|
|
44
|
-
for (Object item : rawSet) {
|
|
45
|
-
stringSet.add(item != null ? item.toString() : "null");
|
|
46
|
-
}
|
|
47
|
-
editor.putStringSet(key, stringSet);
|
|
48
|
-
} else {
|
|
49
|
-
// Convert complex objects to JSON
|
|
50
|
-
String json;
|
|
51
|
-
if (value instanceof JSONObject) {
|
|
52
|
-
json = ((JSONObject) value).toString();
|
|
53
|
-
} else {
|
|
54
|
-
// Use reflection to convert object to JSON string
|
|
55
|
-
try {
|
|
56
|
-
json = objectToJsonString(value);
|
|
57
|
-
} catch (Exception e) {
|
|
58
|
-
// Fallback to string representation
|
|
59
|
-
json = value.toString();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
editor.putString(key, json);
|
|
63
|
-
}
|
|
64
|
-
return editor.commit();
|
|
65
|
-
} catch (Exception e) {
|
|
66
|
-
Log.e("StrataStorage", "Failed to set value in SharedPreferences", e);
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
public Object get(String key) {
|
|
72
|
-
Map<String, ?> all = prefs.getAll();
|
|
73
|
-
return all.get(key);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
public boolean remove(String key) {
|
|
77
|
-
editor.remove(key);
|
|
78
|
-
return editor.commit();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
public boolean clear() {
|
|
82
|
-
return clear(null);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public boolean clear(String prefix) {
|
|
86
|
-
if (prefix != null) {
|
|
87
|
-
// Clear only keys with the given prefix
|
|
88
|
-
Set<String> keysToRemove = new HashSet<>();
|
|
89
|
-
for (String key : prefs.getAll().keySet()) {
|
|
90
|
-
if (key.startsWith(prefix) || key.contains(prefix)) {
|
|
91
|
-
keysToRemove.add(key);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
for (String key : keysToRemove) {
|
|
95
|
-
editor.remove(key);
|
|
96
|
-
}
|
|
97
|
-
} else {
|
|
98
|
-
// Clear all keys
|
|
99
|
-
editor.clear();
|
|
100
|
-
}
|
|
101
|
-
return editor.commit();
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public List<String> keys() {
|
|
105
|
-
return keys(null);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
public List<String> keys(String pattern) {
|
|
109
|
-
Set<String> allKeys = prefs.getAll().keySet();
|
|
110
|
-
|
|
111
|
-
if (pattern == null) {
|
|
112
|
-
return new ArrayList<>(allKeys);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Filter keys by pattern
|
|
116
|
-
List<String> filteredKeys = new ArrayList<>();
|
|
117
|
-
for (String key : allKeys) {
|
|
118
|
-
if (key.startsWith(pattern) || key.contains(pattern)) {
|
|
119
|
-
filteredKeys.add(key);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return filteredKeys;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
public boolean has(String key) {
|
|
126
|
-
return prefs.contains(key);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
public Map<String, ?> getAll() {
|
|
130
|
-
return prefs.getAll();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
public SizeInfo size() {
|
|
134
|
-
Map<String, ?> all = prefs.getAll();
|
|
135
|
-
long totalSize = 0;
|
|
136
|
-
int count = all.size();
|
|
137
|
-
|
|
138
|
-
for (Map.Entry<String, ?> entry : all.entrySet()) {
|
|
139
|
-
String key = entry.getKey();
|
|
140
|
-
Object value = entry.getValue();
|
|
141
|
-
|
|
142
|
-
// Estimate size (key + value in bytes)
|
|
143
|
-
totalSize += key.getBytes().length;
|
|
144
|
-
if (value != null) {
|
|
145
|
-
totalSize += value.toString().getBytes().length;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return new SizeInfo(totalSize, count);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Convert an object to JSON string using reflection
|
|
154
|
-
*/
|
|
155
|
-
private String objectToJsonString(Object obj) throws Exception {
|
|
156
|
-
if (obj == null) {
|
|
157
|
-
return "null";
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
if (obj instanceof String || obj instanceof Number || obj instanceof Boolean) {
|
|
161
|
-
return obj.toString();
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (obj instanceof Map) {
|
|
165
|
-
JSONObject jsonObj = new JSONObject();
|
|
166
|
-
Map<?, ?> map = (Map<?, ?>) obj;
|
|
167
|
-
for (Map.Entry<?, ?> entry : map.entrySet()) {
|
|
168
|
-
String key = entry.getKey().toString();
|
|
169
|
-
jsonObj.put(key, entry.getValue());
|
|
170
|
-
}
|
|
171
|
-
return jsonObj.toString();
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
if (obj instanceof List || obj.getClass().isArray()) {
|
|
175
|
-
JSONArray jsonArray = new JSONArray();
|
|
176
|
-
if (obj instanceof List) {
|
|
177
|
-
List<?> list = (List<?>) obj;
|
|
178
|
-
for (Object item : list) {
|
|
179
|
-
jsonArray.put(item);
|
|
180
|
-
}
|
|
181
|
-
} else {
|
|
182
|
-
Object[] array = (Object[]) obj;
|
|
183
|
-
for (Object item : array) {
|
|
184
|
-
jsonArray.put(item);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
return jsonArray.toString();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// For other objects, create a simple JSON object with their string representation
|
|
191
|
-
JSONObject jsonObj = new JSONObject();
|
|
192
|
-
jsonObj.put("value", obj.toString());
|
|
193
|
-
jsonObj.put("type", obj.getClass().getSimpleName());
|
|
194
|
-
return jsonObj.toString();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Size information class
|
|
199
|
-
*/
|
|
200
|
-
public static class SizeInfo {
|
|
201
|
-
public final long total;
|
|
202
|
-
public final int count;
|
|
203
|
-
|
|
204
|
-
public SizeInfo(long total, int count) {
|
|
205
|
-
this.total = total;
|
|
206
|
-
this.count = count;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|