strata-storage 1.0.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.
Files changed (102) hide show
  1. package/Readme.md +113 -0
  2. package/android/src/main/java/com/strata/storage/EncryptedStorage.java +65 -0
  3. package/android/src/main/java/com/strata/storage/SQLiteStorage.java +147 -0
  4. package/android/src/main/java/com/strata/storage/SharedPreferencesStorage.java +74 -0
  5. package/android/src/main/java/com/stratastorage/StrataStoragePlugin.java +256 -0
  6. package/dist/adapters/capacitor/FilesystemAdapter.d.ts +46 -0
  7. package/dist/adapters/capacitor/FilesystemAdapter.d.ts.map +1 -0
  8. package/dist/adapters/capacitor/FilesystemAdapter.js +162 -0
  9. package/dist/adapters/capacitor/PreferencesAdapter.d.ts +46 -0
  10. package/dist/adapters/capacitor/PreferencesAdapter.d.ts.map +1 -0
  11. package/dist/adapters/capacitor/PreferencesAdapter.js +162 -0
  12. package/dist/adapters/capacitor/SecureAdapter.d.ts +69 -0
  13. package/dist/adapters/capacitor/SecureAdapter.d.ts.map +1 -0
  14. package/dist/adapters/capacitor/SecureAdapter.js +214 -0
  15. package/dist/adapters/capacitor/SqliteAdapter.d.ts +68 -0
  16. package/dist/adapters/capacitor/SqliteAdapter.d.ts.map +1 -0
  17. package/dist/adapters/capacitor/SqliteAdapter.js +277 -0
  18. package/dist/adapters/capacitor/index.d.ts +9 -0
  19. package/dist/adapters/capacitor/index.d.ts.map +1 -0
  20. package/dist/adapters/capacitor/index.js +8 -0
  21. package/dist/adapters/web/CacheAdapter.d.ts +91 -0
  22. package/dist/adapters/web/CacheAdapter.d.ts.map +1 -0
  23. package/dist/adapters/web/CacheAdapter.js +291 -0
  24. package/dist/adapters/web/CookieAdapter.d.ts +77 -0
  25. package/dist/adapters/web/CookieAdapter.d.ts.map +1 -0
  26. package/dist/adapters/web/CookieAdapter.js +260 -0
  27. package/dist/adapters/web/IndexedDBAdapter.d.ts +78 -0
  28. package/dist/adapters/web/IndexedDBAdapter.d.ts.map +1 -0
  29. package/dist/adapters/web/IndexedDBAdapter.js +371 -0
  30. package/dist/adapters/web/LocalStorageAdapter.d.ts +63 -0
  31. package/dist/adapters/web/LocalStorageAdapter.d.ts.map +1 -0
  32. package/dist/adapters/web/LocalStorageAdapter.js +238 -0
  33. package/dist/adapters/web/MemoryAdapter.d.ts +69 -0
  34. package/dist/adapters/web/MemoryAdapter.d.ts.map +1 -0
  35. package/dist/adapters/web/MemoryAdapter.js +165 -0
  36. package/dist/adapters/web/SessionStorageAdapter.d.ts +53 -0
  37. package/dist/adapters/web/SessionStorageAdapter.d.ts.map +1 -0
  38. package/dist/adapters/web/SessionStorageAdapter.js +180 -0
  39. package/dist/adapters/web/index.d.ts +10 -0
  40. package/dist/adapters/web/index.d.ts.map +1 -0
  41. package/dist/adapters/web/index.js +9 -0
  42. package/dist/core/AdapterRegistry.d.ts +52 -0
  43. package/dist/core/AdapterRegistry.d.ts.map +1 -0
  44. package/dist/core/AdapterRegistry.js +102 -0
  45. package/dist/core/BaseAdapter.d.ts +79 -0
  46. package/dist/core/BaseAdapter.d.ts.map +1 -0
  47. package/dist/core/BaseAdapter.js +197 -0
  48. package/dist/core/StorageStrategy.d.ts +55 -0
  49. package/dist/core/StorageStrategy.d.ts.map +1 -0
  50. package/dist/core/StorageStrategy.js +199 -0
  51. package/dist/core/Strata.d.ts +122 -0
  52. package/dist/core/Strata.d.ts.map +1 -0
  53. package/dist/core/Strata.js +568 -0
  54. package/dist/features/compression.d.ts +65 -0
  55. package/dist/features/compression.d.ts.map +1 -0
  56. package/dist/features/compression.js +205 -0
  57. package/dist/features/encryption.d.ts +68 -0
  58. package/dist/features/encryption.d.ts.map +1 -0
  59. package/dist/features/encryption.js +172 -0
  60. package/dist/features/migration.d.ts +17 -0
  61. package/dist/features/migration.d.ts.map +1 -0
  62. package/dist/features/migration.js +43 -0
  63. package/dist/features/query.d.ts +75 -0
  64. package/dist/features/query.d.ts.map +1 -0
  65. package/dist/features/query.js +305 -0
  66. package/dist/features/sync.d.ts +87 -0
  67. package/dist/features/sync.d.ts.map +1 -0
  68. package/dist/features/sync.js +233 -0
  69. package/dist/features/ttl.d.ts +124 -0
  70. package/dist/features/ttl.d.ts.map +1 -0
  71. package/dist/features/ttl.js +236 -0
  72. package/dist/index.d.ts +44 -0
  73. package/dist/index.d.ts.map +1 -0
  74. package/dist/index.js +46 -0
  75. package/dist/package.json +60 -0
  76. package/dist/plugin/definitions.d.ts +219 -0
  77. package/dist/plugin/definitions.d.ts.map +1 -0
  78. package/dist/plugin/definitions.js +5 -0
  79. package/dist/plugin/index.d.ts +8 -0
  80. package/dist/plugin/index.d.ts.map +1 -0
  81. package/dist/plugin/index.js +27 -0
  82. package/dist/plugin/web.d.ts +24 -0
  83. package/dist/plugin/web.d.ts.map +1 -0
  84. package/dist/plugin/web.js +35 -0
  85. package/dist/types/index.d.ts +558 -0
  86. package/dist/types/index.d.ts.map +1 -0
  87. package/dist/types/index.js +14 -0
  88. package/dist/utils/errors.d.ts +92 -0
  89. package/dist/utils/errors.d.ts.map +1 -0
  90. package/dist/utils/errors.js +153 -0
  91. package/dist/utils/index.d.ts +105 -0
  92. package/dist/utils/index.d.ts.map +1 -0
  93. package/dist/utils/index.js +329 -0
  94. package/ios/Plugin/KeychainStorage.swift +87 -0
  95. package/ios/Plugin/SQLiteStorage.swift +167 -0
  96. package/ios/Plugin/StrataStoragePlugin.swift +204 -0
  97. package/ios/Plugin/UserDefaultsStorage.swift +44 -0
  98. package/package.json +126 -0
  99. package/scripts/build.js +52 -0
  100. package/scripts/cli.js +60 -0
  101. package/scripts/configure.js +444 -0
  102. package/scripts/postinstall.js +33 -0
@@ -0,0 +1,124 @@
1
+ /**
2
+ * TTL (Time To Live) Manager
3
+ * Handles automatic expiration of storage items
4
+ */
5
+ import type { StorageValue } from '@/types';
6
+ import { EventEmitter } from '@/utils';
7
+ export interface TTLConfig {
8
+ /**
9
+ * Default TTL in milliseconds
10
+ */
11
+ defaultTTL?: number;
12
+ /**
13
+ * Cleanup interval in milliseconds (default: 60000 - 1 minute)
14
+ */
15
+ cleanupInterval?: number;
16
+ /**
17
+ * Enable automatic cleanup (default: true)
18
+ */
19
+ autoCleanup?: boolean;
20
+ /**
21
+ * Maximum number of items to check per cleanup cycle
22
+ */
23
+ batchSize?: number;
24
+ /**
25
+ * Callback when items expire
26
+ */
27
+ onExpire?: (keys: string[]) => void;
28
+ }
29
+ export interface TTLOptions {
30
+ /**
31
+ * TTL in milliseconds
32
+ */
33
+ ttl?: number;
34
+ /**
35
+ * Sliding expiration - reset TTL on access
36
+ */
37
+ sliding?: boolean;
38
+ /**
39
+ * Expire at specific time (overrides ttl)
40
+ */
41
+ expireAt?: Date | number;
42
+ /**
43
+ * Expire after a certain date
44
+ */
45
+ expireAfter?: Date | number;
46
+ }
47
+ export interface ExpiredItem {
48
+ key: string;
49
+ value: unknown;
50
+ expiredAt: number;
51
+ }
52
+ /**
53
+ * TTL Manager for handling item expiration
54
+ */
55
+ export declare class TTLManager extends EventEmitter {
56
+ private config;
57
+ private cleanupInterval?;
58
+ private cleanupCallbacks;
59
+ constructor(config?: TTLConfig);
60
+ /**
61
+ * Calculate expiration timestamp
62
+ */
63
+ calculateExpiration(options?: TTLOptions): number | undefined;
64
+ /**
65
+ * Check if a value is expired
66
+ */
67
+ isExpired(value: StorageValue): boolean;
68
+ /**
69
+ * Update expiration for sliding TTL
70
+ */
71
+ updateExpiration(value: StorageValue, options?: TTLOptions): StorageValue;
72
+ /**
73
+ * Start automatic cleanup
74
+ */
75
+ startAutoCleanup(getKeys: () => Promise<string[]>, getItem: (key: string) => Promise<StorageValue | null>, removeItem: (key: string) => Promise<void>): void;
76
+ /**
77
+ * Stop automatic cleanup
78
+ */
79
+ stopAutoCleanup(): void;
80
+ /**
81
+ * Perform cleanup of expired items
82
+ */
83
+ cleanup(getKeys: () => Promise<string[]>, getItem: (key: string) => Promise<StorageValue | null>, removeItem: (key: string) => Promise<void>): Promise<ExpiredItem[]>;
84
+ /**
85
+ * Register a cleanup callback for a specific key
86
+ */
87
+ onCleanup(key: string, callback: () => Promise<void>): void;
88
+ /**
89
+ * Remove cleanup callback
90
+ */
91
+ removeCleanupCallback(key: string): void;
92
+ /**
93
+ * Get all items that will expire within a time window
94
+ */
95
+ getExpiring(timeWindow: number, getKeys: () => Promise<string[]>, getItem: (key: string) => Promise<StorageValue | null>): Promise<Array<{
96
+ key: string;
97
+ expiresIn: number;
98
+ }>>;
99
+ /**
100
+ * Extend TTL for a key
101
+ */
102
+ extendTTL(value: StorageValue, extension: number): StorageValue;
103
+ /**
104
+ * Set item to never expire
105
+ */
106
+ persist(value: StorageValue): StorageValue;
107
+ /**
108
+ * Get time until expiration
109
+ */
110
+ getTimeToLive(value: StorageValue): number | null;
111
+ /**
112
+ * Format TTL for display
113
+ */
114
+ formatTTL(milliseconds: number): string;
115
+ /**
116
+ * Clear all data
117
+ */
118
+ clear(): void;
119
+ }
120
+ /**
121
+ * Create a TTL manager instance
122
+ */
123
+ export declare function createTTLManager(config?: TTLConfig): TTLManager;
124
+ //# sourceMappingURL=ttl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ttl.d.ts","sourceRoot":"","sources":["../../src/features/ttl.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACrC;AAED,MAAM,WAAW,UAAU;IACzB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E,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GACzC,OAAO,CAAC,WAAW,EAAE,CAAC;IA0CzB;;OAEG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAI3D;;OAEG;IACH,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAIxC;;OAEG;IACG,WAAW,CACf,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC,EAChC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,GACrD,OAAO,CAAC,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAmBrD;;OAEG;IACH,SAAS,CAAC,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,YAAY;IAgB/D;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,YAAY;IAQ1C;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI;IAMjD;;OAEG;IACH,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IAiBvC;;OAEG;IACH,KAAK,IAAI,IAAI;CAKd;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,SAAS,GAAG,UAAU,CAE/D"}
@@ -0,0 +1,236 @@
1
+ /**
2
+ * TTL (Time To Live) Manager
3
+ * Handles automatic expiration of storage items
4
+ */
5
+ import { EventEmitter } from '@/utils';
6
+ /**
7
+ * TTL Manager for handling item expiration
8
+ */
9
+ export class TTLManager extends EventEmitter {
10
+ config;
11
+ cleanupInterval;
12
+ cleanupCallbacks = new Map();
13
+ constructor(config = {}) {
14
+ super();
15
+ this.config = {
16
+ defaultTTL: config.defaultTTL || 0,
17
+ cleanupInterval: config.cleanupInterval || 60000,
18
+ autoCleanup: config.autoCleanup ?? true,
19
+ batchSize: config.batchSize || 100,
20
+ onExpire: config.onExpire || (() => { }),
21
+ };
22
+ }
23
+ /**
24
+ * Calculate expiration timestamp
25
+ */
26
+ calculateExpiration(options) {
27
+ if (!options) {
28
+ return this.config.defaultTTL ? Date.now() + this.config.defaultTTL : undefined;
29
+ }
30
+ // Specific expiration time takes precedence
31
+ if (options.expireAt) {
32
+ const time = options.expireAt instanceof Date ? options.expireAt.getTime() : options.expireAt;
33
+ return time > Date.now() ? time : undefined;
34
+ }
35
+ // Expire after a certain date
36
+ if (options.expireAfter) {
37
+ const afterTime = options.expireAfter instanceof Date ? options.expireAfter.getTime() : options.expireAfter;
38
+ return afterTime;
39
+ }
40
+ // TTL from now
41
+ if (options.ttl) {
42
+ return Date.now() + options.ttl;
43
+ }
44
+ // Use default TTL
45
+ return this.config.defaultTTL ? Date.now() + this.config.defaultTTL : undefined;
46
+ }
47
+ /**
48
+ * Check if a value is expired
49
+ */
50
+ isExpired(value) {
51
+ if (!value.expires)
52
+ return false;
53
+ return Date.now() > value.expires;
54
+ }
55
+ /**
56
+ * Update expiration for sliding TTL
57
+ */
58
+ updateExpiration(value, options) {
59
+ if (!options?.sliding || !value.expires) {
60
+ return value;
61
+ }
62
+ const ttl = options.ttl || this.config.defaultTTL;
63
+ if (!ttl)
64
+ return value;
65
+ return {
66
+ ...value,
67
+ expires: Date.now() + ttl,
68
+ updated: Date.now(),
69
+ };
70
+ }
71
+ /**
72
+ * Start automatic cleanup
73
+ */
74
+ startAutoCleanup(getKeys, getItem, removeItem) {
75
+ if (!this.config.autoCleanup || this.cleanupInterval) {
76
+ return;
77
+ }
78
+ this.cleanupInterval = setInterval(async () => {
79
+ try {
80
+ await this.cleanup(getKeys, getItem, removeItem);
81
+ }
82
+ catch (error) {
83
+ this.emit('error', error);
84
+ }
85
+ }, this.config.cleanupInterval);
86
+ }
87
+ /**
88
+ * Stop automatic cleanup
89
+ */
90
+ stopAutoCleanup() {
91
+ if (this.cleanupInterval) {
92
+ clearInterval(this.cleanupInterval);
93
+ this.cleanupInterval = undefined;
94
+ }
95
+ }
96
+ /**
97
+ * Perform cleanup of expired items
98
+ */
99
+ async cleanup(getKeys, getItem, removeItem) {
100
+ const keys = await getKeys();
101
+ const expired = [];
102
+ const expiredKeys = [];
103
+ const now = Date.now();
104
+ let processed = 0;
105
+ for (const key of keys) {
106
+ if (processed >= this.config.batchSize) {
107
+ // Process remaining in next cycle
108
+ break;
109
+ }
110
+ const item = await getItem(key);
111
+ if (item && item.expires && now > item.expires) {
112
+ expired.push({
113
+ key,
114
+ value: item.value,
115
+ expiredAt: now,
116
+ });
117
+ expiredKeys.push(key);
118
+ await removeItem(key);
119
+ // Execute any registered cleanup callbacks
120
+ const callback = this.cleanupCallbacks.get(key);
121
+ if (callback) {
122
+ await callback();
123
+ this.cleanupCallbacks.delete(key);
124
+ }
125
+ }
126
+ processed++;
127
+ }
128
+ if (expiredKeys.length > 0) {
129
+ this.emit('expired', expiredKeys);
130
+ this.config.onExpire(expiredKeys);
131
+ }
132
+ return expired;
133
+ }
134
+ /**
135
+ * Register a cleanup callback for a specific key
136
+ */
137
+ onCleanup(key, callback) {
138
+ this.cleanupCallbacks.set(key, callback);
139
+ }
140
+ /**
141
+ * Remove cleanup callback
142
+ */
143
+ removeCleanupCallback(key) {
144
+ this.cleanupCallbacks.delete(key);
145
+ }
146
+ /**
147
+ * Get all items that will expire within a time window
148
+ */
149
+ async getExpiring(timeWindow, getKeys, getItem) {
150
+ const keys = await getKeys();
151
+ const expiring = [];
152
+ const now = Date.now();
153
+ const windowEnd = now + timeWindow;
154
+ for (const key of keys) {
155
+ const item = await getItem(key);
156
+ if (item && item.expires && item.expires > now && item.expires <= windowEnd) {
157
+ expiring.push({
158
+ key,
159
+ expiresIn: item.expires - now,
160
+ });
161
+ }
162
+ }
163
+ return expiring.sort((a, b) => a.expiresIn - b.expiresIn);
164
+ }
165
+ /**
166
+ * Extend TTL for a key
167
+ */
168
+ extendTTL(value, extension) {
169
+ if (!value.expires) {
170
+ return {
171
+ ...value,
172
+ expires: Date.now() + extension,
173
+ updated: Date.now(),
174
+ };
175
+ }
176
+ return {
177
+ ...value,
178
+ expires: value.expires + extension,
179
+ updated: Date.now(),
180
+ };
181
+ }
182
+ /**
183
+ * Set item to never expire
184
+ */
185
+ persist(value) {
186
+ const { expires: _, ...persistedValue } = value;
187
+ return {
188
+ ...persistedValue,
189
+ updated: Date.now(),
190
+ };
191
+ }
192
+ /**
193
+ * Get time until expiration
194
+ */
195
+ getTimeToLive(value) {
196
+ if (!value.expires)
197
+ return null;
198
+ const ttl = value.expires - Date.now();
199
+ return ttl > 0 ? ttl : 0;
200
+ }
201
+ /**
202
+ * Format TTL for display
203
+ */
204
+ formatTTL(milliseconds) {
205
+ const seconds = Math.floor(milliseconds / 1000);
206
+ const minutes = Math.floor(seconds / 60);
207
+ const hours = Math.floor(minutes / 60);
208
+ const days = Math.floor(hours / 24);
209
+ if (days > 0) {
210
+ return `${days}d ${hours % 24}h`;
211
+ }
212
+ else if (hours > 0) {
213
+ return `${hours}h ${minutes % 60}m`;
214
+ }
215
+ else if (minutes > 0) {
216
+ return `${minutes}m ${seconds % 60}s`;
217
+ }
218
+ else {
219
+ return `${seconds}s`;
220
+ }
221
+ }
222
+ /**
223
+ * Clear all data
224
+ */
225
+ clear() {
226
+ this.stopAutoCleanup();
227
+ this.cleanupCallbacks.clear();
228
+ this.removeAllListeners();
229
+ }
230
+ }
231
+ /**
232
+ * Create a TTL manager instance
233
+ */
234
+ export function createTTLManager(config) {
235
+ return new TTLManager(config);
236
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Strata Storage - Zero-dependency universal storage plugin
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { Strata } from './core/Strata';
7
+ import { Strata } from './core/Strata';
8
+ export type { Platform, StorageType, StorageStrategy, StorageOptions, StorageValue, StorageChange, StorageCapabilities, StrataConfig, StorageAdapter, Transaction, ClearOptions, SizeInfo, ExportOptions, ImportOptions, QueryCondition, QueryOperators, SubscriptionCallback, UnsubscribeFunction, Migration, ExportFormat, } from './types';
9
+ export { StrataError, StorageError, NotFoundError, QuotaExceededError, AdapterNotAvailableError, NotSupportedError, EncryptionError, CompressionError, SerializationError, ValidationError, TransactionError, MigrationError, SyncError, isStrataError, isQuotaError, } from './utils/errors';
10
+ export { serialize, deserialize, deepClone, deepMerge, formatBytes, parseSize, EventEmitter, } from './utils';
11
+ export { BaseAdapter } from './core/BaseAdapter';
12
+ export { AdapterRegistry } from './core/AdapterRegistry';
13
+ export { EncryptionManager } from './features/encryption';
14
+ export type { EncryptionConfig, EncryptedData } from './features/encryption';
15
+ export { CompressionManager } from './features/compression';
16
+ export type { CompressionConfig, CompressedData } from './features/compression';
17
+ export { SyncManager, createSyncManager } from './features/sync';
18
+ export type { SyncConfig, SyncMessage } from './features/sync';
19
+ export { QueryEngine, createQueryEngine } from './features/query';
20
+ export { TTLManager, createTTLManager } from './features/ttl';
21
+ export type { TTLConfig, TTLOptions, ExpiredItem } from './features/ttl';
22
+ export { MigrationManager } from './features/migration';
23
+ export * from './plugin/definitions';
24
+ export { StrataStorage } from './plugin';
25
+ /**
26
+ * Create a new Strata instance with optional configuration
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * import { Strata } from 'strata-storage';
31
+ *
32
+ * const storage = new Strata({
33
+ * defaultStorages: ['indexedDB', 'localStorage', 'memory'],
34
+ * encryption: { enabled: true },
35
+ * compression: { enabled: true }
36
+ * });
37
+ *
38
+ * await storage.initialize();
39
+ * await storage.set('key', 'value');
40
+ * const value = await storage.get('key');
41
+ * ```
42
+ */
43
+ export declare function createStrata(config?: import('./types').StrataConfig): InstanceType<typeof Strata>;
44
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;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MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC9D,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO,SAAS,EAAE,YAAY,GAAG,YAAY,CAAC,OAAO,MAAM,CAAC,CAEjG"}
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Strata Storage - Zero-dependency universal storage plugin
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ // Main export
7
+ export { Strata } from './core/Strata';
8
+ import { Strata } from './core/Strata';
9
+ // Errors
10
+ export { StrataError, StorageError, NotFoundError, QuotaExceededError, AdapterNotAvailableError, NotSupportedError, EncryptionError, CompressionError, SerializationError, ValidationError, TransactionError, MigrationError, SyncError, isStrataError, isQuotaError, } from './utils/errors';
11
+ // Utilities (selected exports for advanced users)
12
+ export { serialize, deserialize, deepClone, deepMerge, formatBytes, parseSize, EventEmitter, } from './utils';
13
+ // Base classes for custom adapters
14
+ export { BaseAdapter } from './core/BaseAdapter';
15
+ export { AdapterRegistry } from './core/AdapterRegistry';
16
+ // Features
17
+ export { EncryptionManager } from './features/encryption';
18
+ export { CompressionManager } from './features/compression';
19
+ export { SyncManager, createSyncManager } from './features/sync';
20
+ export { QueryEngine, createQueryEngine } from './features/query';
21
+ export { TTLManager, createTTLManager } from './features/ttl';
22
+ export { MigrationManager } from './features/migration';
23
+ // Plugin definitions and main plugin
24
+ export * from './plugin/definitions';
25
+ export { StrataStorage } from './plugin';
26
+ /**
27
+ * Create a new Strata instance with optional configuration
28
+ *
29
+ * @example
30
+ * ```typescript
31
+ * import { Strata } from 'strata-storage';
32
+ *
33
+ * const storage = new Strata({
34
+ * defaultStorages: ['indexedDB', 'localStorage', 'memory'],
35
+ * encryption: { enabled: true },
36
+ * compression: { enabled: true }
37
+ * });
38
+ *
39
+ * await storage.initialize();
40
+ * await storage.set('key', 'value');
41
+ * const value = await storage.get('key');
42
+ * ```
43
+ */
44
+ export function createStrata(config) {
45
+ return new Strata(config);
46
+ }
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "strata-storage",
3
+ "version": "1.0.0",
4
+ "description": "Zero-dependency universal storage plugin providing a unified API for all storage operations across web, Android, and iOS platforms",
5
+ "main": "index.js",
6
+ "module": "index.esm.js",
7
+ "types": "index.d.ts",
8
+ "author": "Ahsan Mahmood",
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/aoneahsan/strata-storage.git"
13
+ },
14
+ "keywords": [
15
+ "storage",
16
+ "capacitor",
17
+ "ionic",
18
+ "react",
19
+ "vue",
20
+ "angular",
21
+ "localStorage",
22
+ "indexedDB",
23
+ "sqlite",
24
+ "keychain",
25
+ "preferences",
26
+ "zero-dependencies",
27
+ "cross-platform",
28
+ "web",
29
+ "ios",
30
+ "android"
31
+ ],
32
+ "peerDependencies": {
33
+ "@angular/core": ">=12.0.0",
34
+ "@capacitor/core": "^5.0.0 || ^6.0.0",
35
+ "react": ">=16.8.0",
36
+ "vue": ">=3.0.0"
37
+ },
38
+ "peerDependenciesMeta": {
39
+ "@capacitor/core": {
40
+ "optional": true
41
+ },
42
+ "react": {
43
+ "optional": true
44
+ },
45
+ "vue": {
46
+ "optional": true
47
+ },
48
+ "@angular/core": {
49
+ "optional": true
50
+ }
51
+ },
52
+ "capacitor": {
53
+ "ios": {
54
+ "src": "ios"
55
+ },
56
+ "android": {
57
+ "src": "android"
58
+ }
59
+ }
60
+ }