@soulcraft/brainy 3.50.1 → 4.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.
- package/CHANGELOG.md +242 -0
- package/README.md +358 -658
- package/dist/api/ConfigAPI.js +56 -19
- package/dist/api/DataAPI.js +24 -18
- package/dist/augmentations/storageAugmentations.d.ts +24 -0
- package/dist/augmentations/storageAugmentations.js +22 -0
- package/dist/brainy.js +32 -9
- package/dist/cli/commands/core.d.ts +20 -10
- package/dist/cli/commands/core.js +384 -82
- package/dist/cli/commands/import.d.ts +41 -0
- package/dist/cli/commands/import.js +456 -0
- package/dist/cli/commands/insights.d.ts +34 -0
- package/dist/cli/commands/insights.js +300 -0
- package/dist/cli/commands/neural.d.ts +6 -12
- package/dist/cli/commands/neural.js +113 -10
- package/dist/cli/commands/nlp.d.ts +28 -0
- package/dist/cli/commands/nlp.js +246 -0
- package/dist/cli/commands/storage.d.ts +64 -0
- package/dist/cli/commands/storage.js +730 -0
- package/dist/cli/index.js +210 -24
- package/dist/coreTypes.d.ts +206 -34
- package/dist/distributed/configManager.js +8 -6
- package/dist/distributed/shardMigration.js +2 -0
- package/dist/distributed/storageDiscovery.js +6 -4
- package/dist/embeddings/EmbeddingManager.d.ts +2 -2
- package/dist/embeddings/EmbeddingManager.js +5 -1
- package/dist/graph/lsm/LSMTree.js +32 -20
- package/dist/hnsw/typeAwareHNSWIndex.js +6 -2
- package/dist/storage/adapters/azureBlobStorage.d.ts +545 -0
- package/dist/storage/adapters/azureBlobStorage.js +1809 -0
- package/dist/storage/adapters/baseStorageAdapter.d.ts +16 -13
- package/dist/storage/adapters/fileSystemStorage.d.ts +21 -9
- package/dist/storage/adapters/fileSystemStorage.js +204 -127
- package/dist/storage/adapters/gcsStorage.d.ts +119 -9
- package/dist/storage/adapters/gcsStorage.js +317 -62
- package/dist/storage/adapters/memoryStorage.d.ts +30 -18
- package/dist/storage/adapters/memoryStorage.js +99 -94
- package/dist/storage/adapters/opfsStorage.d.ts +48 -10
- package/dist/storage/adapters/opfsStorage.js +201 -80
- package/dist/storage/adapters/r2Storage.d.ts +12 -5
- package/dist/storage/adapters/r2Storage.js +63 -15
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +164 -17
- package/dist/storage/adapters/s3CompatibleStorage.js +472 -80
- package/dist/storage/adapters/typeAwareStorageAdapter.d.ts +38 -6
- package/dist/storage/adapters/typeAwareStorageAdapter.js +218 -39
- package/dist/storage/baseStorage.d.ts +41 -38
- package/dist/storage/baseStorage.js +110 -134
- package/dist/storage/storageFactory.d.ts +29 -2
- package/dist/storage/storageFactory.js +30 -1
- package/dist/utils/entityIdMapper.js +5 -2
- package/dist/utils/fieldTypeInference.js +8 -1
- package/dist/utils/metadataFilter.d.ts +3 -2
- package/dist/utils/metadataFilter.js +1 -0
- package/dist/utils/metadataIndex.d.ts +2 -1
- package/dist/utils/metadataIndex.js +9 -1
- package/dist/utils/metadataIndexChunking.js +9 -4
- package/dist/utils/periodicCleanup.js +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Azure Blob Storage Adapter (Native)
|
|
3
|
+
* Uses the native @azure/storage-blob library for optimal performance and authentication
|
|
4
|
+
*
|
|
5
|
+
* Supports multiple authentication methods:
|
|
6
|
+
* 1. DefaultAzureCredential (Managed Identity) - Automatic in Azure environments
|
|
7
|
+
* 2. Connection String
|
|
8
|
+
* 3. Storage Account Key
|
|
9
|
+
* 4. SAS Token
|
|
10
|
+
* 5. Azure AD (OAuth2) via DefaultAzureCredential
|
|
11
|
+
*
|
|
12
|
+
* v4.0.0: Fully compatible with metadata/vector separation architecture
|
|
13
|
+
*/
|
|
14
|
+
import { HNSWNoun, HNSWVerb, HNSWNounWithMetadata, HNSWVerbWithMetadata, StatisticsData } from '../../coreTypes.js';
|
|
15
|
+
import { BaseStorage } from '../baseStorage.js';
|
|
16
|
+
type HNSWNode = HNSWNoun;
|
|
17
|
+
type Edge = HNSWVerb;
|
|
18
|
+
/**
|
|
19
|
+
* Native Azure Blob Storage adapter for server environments
|
|
20
|
+
* Uses the @azure/storage-blob library with DefaultAzureCredential
|
|
21
|
+
*
|
|
22
|
+
* Authentication priority:
|
|
23
|
+
* 1. DefaultAzureCredential (Managed Identity) - if no credentials provided
|
|
24
|
+
* 2. Connection String - if connectionString provided
|
|
25
|
+
* 3. Storage Account Key - if accountName + accountKey provided
|
|
26
|
+
* 4. SAS Token - if accountName + sasToken provided
|
|
27
|
+
*/
|
|
28
|
+
export declare class AzureBlobStorage extends BaseStorage {
|
|
29
|
+
private blobServiceClient;
|
|
30
|
+
private containerClient;
|
|
31
|
+
private containerName;
|
|
32
|
+
private accountName?;
|
|
33
|
+
private accountKey?;
|
|
34
|
+
private connectionString?;
|
|
35
|
+
private sasToken?;
|
|
36
|
+
private nounPrefix;
|
|
37
|
+
private verbPrefix;
|
|
38
|
+
private metadataPrefix;
|
|
39
|
+
private verbMetadataPrefix;
|
|
40
|
+
private systemPrefix;
|
|
41
|
+
protected statisticsCache: StatisticsData | null;
|
|
42
|
+
private pendingOperations;
|
|
43
|
+
private consecutiveErrors;
|
|
44
|
+
private lastErrorReset;
|
|
45
|
+
private backpressure;
|
|
46
|
+
private nounWriteBuffer;
|
|
47
|
+
private verbWriteBuffer;
|
|
48
|
+
private requestCoalescer;
|
|
49
|
+
private highVolumeMode;
|
|
50
|
+
private lastVolumeCheck;
|
|
51
|
+
private volumeCheckInterval;
|
|
52
|
+
private forceHighVolumeMode;
|
|
53
|
+
private nounCacheManager;
|
|
54
|
+
private verbCacheManager;
|
|
55
|
+
private logger;
|
|
56
|
+
/**
|
|
57
|
+
* Initialize the storage adapter
|
|
58
|
+
* @param options Configuration options for Azure Blob Storage
|
|
59
|
+
*/
|
|
60
|
+
constructor(options: {
|
|
61
|
+
containerName: string;
|
|
62
|
+
connectionString?: string;
|
|
63
|
+
accountName?: string;
|
|
64
|
+
accountKey?: string;
|
|
65
|
+
sasToken?: string;
|
|
66
|
+
cacheConfig?: {
|
|
67
|
+
hotCacheMaxSize?: number;
|
|
68
|
+
hotCacheEvictionThreshold?: number;
|
|
69
|
+
warmCacheTTL?: number;
|
|
70
|
+
};
|
|
71
|
+
readOnly?: boolean;
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* Initialize the storage adapter
|
|
75
|
+
*/
|
|
76
|
+
init(): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Get the Azure blob name for a noun using UUID-based sharding
|
|
79
|
+
*
|
|
80
|
+
* Uses first 2 hex characters of UUID for consistent sharding.
|
|
81
|
+
* Path format: entities/nouns/vectors/{shardId}/{uuid}.json
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* getNounKey('ab123456-1234-5678-9abc-def012345678')
|
|
85
|
+
* // returns 'entities/nouns/vectors/ab/ab123456-1234-5678-9abc-def012345678.json'
|
|
86
|
+
*/
|
|
87
|
+
private getNounKey;
|
|
88
|
+
/**
|
|
89
|
+
* Get the Azure blob name for a verb using UUID-based sharding
|
|
90
|
+
*
|
|
91
|
+
* Uses first 2 hex characters of UUID for consistent sharding.
|
|
92
|
+
* Path format: entities/verbs/vectors/{shardId}/{uuid}.json
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* getVerbKey('cd987654-4321-8765-cba9-fed543210987')
|
|
96
|
+
* // returns 'entities/verbs/vectors/cd/cd987654-4321-8765-cba9-fed543210987.json'
|
|
97
|
+
*/
|
|
98
|
+
private getVerbKey;
|
|
99
|
+
/**
|
|
100
|
+
* Override base class method to detect Azure-specific throttling errors
|
|
101
|
+
*/
|
|
102
|
+
protected isThrottlingError(error: any): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Override base class to enable smart batching for cloud storage
|
|
105
|
+
*
|
|
106
|
+
* Azure Blob Storage is cloud storage with network latency (~50ms per write).
|
|
107
|
+
* Smart batching reduces writes from 1000 ops → 100 batches.
|
|
108
|
+
*
|
|
109
|
+
* @returns true (Azure is cloud storage)
|
|
110
|
+
*/
|
|
111
|
+
protected isCloudStorage(): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Apply backpressure before starting an operation
|
|
114
|
+
* @returns Request ID for tracking
|
|
115
|
+
*/
|
|
116
|
+
private applyBackpressure;
|
|
117
|
+
/**
|
|
118
|
+
* Release backpressure after completing an operation
|
|
119
|
+
* @param success Whether the operation succeeded
|
|
120
|
+
* @param requestId Request ID from applyBackpressure()
|
|
121
|
+
*/
|
|
122
|
+
private releaseBackpressure;
|
|
123
|
+
/**
|
|
124
|
+
* Check if high-volume mode should be enabled
|
|
125
|
+
*/
|
|
126
|
+
private checkVolumeMode;
|
|
127
|
+
/**
|
|
128
|
+
* Flush noun buffer to Azure
|
|
129
|
+
*/
|
|
130
|
+
private flushNounBuffer;
|
|
131
|
+
/**
|
|
132
|
+
* Flush verb buffer to Azure
|
|
133
|
+
*/
|
|
134
|
+
private flushVerbBuffer;
|
|
135
|
+
/**
|
|
136
|
+
* Save a noun to storage (internal implementation)
|
|
137
|
+
*/
|
|
138
|
+
protected saveNoun_internal(noun: HNSWNoun): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Save a node to storage
|
|
141
|
+
*/
|
|
142
|
+
protected saveNode(node: HNSWNode): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Save a node directly to Azure (bypass buffer)
|
|
145
|
+
*/
|
|
146
|
+
private saveNodeDirect;
|
|
147
|
+
/**
|
|
148
|
+
* Get a noun from storage (internal implementation)
|
|
149
|
+
* v4.0.0: Returns ONLY vector data (no metadata field)
|
|
150
|
+
* Base class combines with metadata via getNoun() -> HNSWNounWithMetadata
|
|
151
|
+
*/
|
|
152
|
+
protected getNoun_internal(id: string): Promise<HNSWNoun | null>;
|
|
153
|
+
/**
|
|
154
|
+
* Get a node from storage
|
|
155
|
+
*/
|
|
156
|
+
protected getNode(id: string): Promise<HNSWNode | null>;
|
|
157
|
+
/**
|
|
158
|
+
* Delete a noun from storage (internal implementation)
|
|
159
|
+
*/
|
|
160
|
+
protected deleteNoun_internal(id: string): Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* Write an object to a specific path in Azure
|
|
163
|
+
* Primitive operation required by base class
|
|
164
|
+
* @protected
|
|
165
|
+
*/
|
|
166
|
+
protected writeObjectToPath(path: string, data: any): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Read an object from a specific path in Azure
|
|
169
|
+
* Primitive operation required by base class
|
|
170
|
+
* @protected
|
|
171
|
+
*/
|
|
172
|
+
protected readObjectFromPath(path: string): Promise<any | null>;
|
|
173
|
+
/**
|
|
174
|
+
* Delete an object from a specific path in Azure
|
|
175
|
+
* Primitive operation required by base class
|
|
176
|
+
* @protected
|
|
177
|
+
*/
|
|
178
|
+
protected deleteObjectFromPath(path: string): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Batch delete multiple blobs from Azure Blob Storage
|
|
181
|
+
* Deletes up to 256 blobs per batch (Azure limit)
|
|
182
|
+
* Handles throttling, retries, and partial failures
|
|
183
|
+
*
|
|
184
|
+
* @param keys - Array of blob names (paths) to delete
|
|
185
|
+
* @param options - Configuration options for batch deletion
|
|
186
|
+
* @returns Statistics about successful and failed deletions
|
|
187
|
+
*/
|
|
188
|
+
batchDelete(keys: string[], options?: {
|
|
189
|
+
maxRetries?: number;
|
|
190
|
+
retryDelayMs?: number;
|
|
191
|
+
continueOnError?: boolean;
|
|
192
|
+
}): Promise<{
|
|
193
|
+
totalRequested: number;
|
|
194
|
+
successfulDeletes: number;
|
|
195
|
+
failedDeletes: number;
|
|
196
|
+
errors: Array<{
|
|
197
|
+
key: string;
|
|
198
|
+
error: string;
|
|
199
|
+
}>;
|
|
200
|
+
}>;
|
|
201
|
+
/**
|
|
202
|
+
* List all objects under a specific prefix in Azure
|
|
203
|
+
* Primitive operation required by base class
|
|
204
|
+
* @protected
|
|
205
|
+
*/
|
|
206
|
+
protected listObjectsUnderPath(prefix: string): Promise<string[]>;
|
|
207
|
+
/**
|
|
208
|
+
* Helper: Convert Azure stream to buffer
|
|
209
|
+
*/
|
|
210
|
+
private streamToBuffer;
|
|
211
|
+
/**
|
|
212
|
+
* Save a verb to storage (internal implementation)
|
|
213
|
+
*/
|
|
214
|
+
protected saveVerb_internal(verb: HNSWVerb): Promise<void>;
|
|
215
|
+
/**
|
|
216
|
+
* Save an edge to storage
|
|
217
|
+
*/
|
|
218
|
+
protected saveEdge(edge: Edge): Promise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* Save an edge directly to Azure (bypass buffer)
|
|
221
|
+
*/
|
|
222
|
+
private saveEdgeDirect;
|
|
223
|
+
/**
|
|
224
|
+
* Get a verb from storage (internal implementation)
|
|
225
|
+
* v4.0.0: Returns ONLY vector + core relational fields (no metadata field)
|
|
226
|
+
* Base class combines with metadata via getVerb() -> HNSWVerbWithMetadata
|
|
227
|
+
*/
|
|
228
|
+
protected getVerb_internal(id: string): Promise<HNSWVerb | null>;
|
|
229
|
+
/**
|
|
230
|
+
* Get an edge from storage
|
|
231
|
+
*/
|
|
232
|
+
protected getEdge(id: string): Promise<Edge | null>;
|
|
233
|
+
/**
|
|
234
|
+
* Delete a verb from storage (internal implementation)
|
|
235
|
+
*/
|
|
236
|
+
protected deleteVerb_internal(id: string): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Get nouns with pagination
|
|
239
|
+
* v4.0.0: Returns HNSWNounWithMetadata[] (includes metadata field)
|
|
240
|
+
* Iterates through all UUID-based shards (00-ff) for consistent pagination
|
|
241
|
+
*/
|
|
242
|
+
getNounsWithPagination(options?: {
|
|
243
|
+
limit?: number;
|
|
244
|
+
cursor?: string;
|
|
245
|
+
filter?: {
|
|
246
|
+
nounType?: string | string[];
|
|
247
|
+
service?: string | string[];
|
|
248
|
+
metadata?: Record<string, any>;
|
|
249
|
+
};
|
|
250
|
+
}): Promise<{
|
|
251
|
+
items: HNSWNounWithMetadata[];
|
|
252
|
+
totalCount?: number;
|
|
253
|
+
hasMore: boolean;
|
|
254
|
+
nextCursor?: string;
|
|
255
|
+
}>;
|
|
256
|
+
/**
|
|
257
|
+
* Get nouns by noun type (internal implementation)
|
|
258
|
+
*/
|
|
259
|
+
protected getNounsByNounType_internal(nounType: string): Promise<HNSWNoun[]>;
|
|
260
|
+
/**
|
|
261
|
+
* Get verbs by source ID (internal implementation)
|
|
262
|
+
*/
|
|
263
|
+
protected getVerbsBySource_internal(sourceId: string): Promise<HNSWVerbWithMetadata[]>;
|
|
264
|
+
/**
|
|
265
|
+
* Get verbs by target ID (internal implementation)
|
|
266
|
+
*/
|
|
267
|
+
protected getVerbsByTarget_internal(targetId: string): Promise<HNSWVerbWithMetadata[]>;
|
|
268
|
+
/**
|
|
269
|
+
* Get verbs by type (internal implementation)
|
|
270
|
+
*/
|
|
271
|
+
protected getVerbsByType_internal(type: string): Promise<HNSWVerbWithMetadata[]>;
|
|
272
|
+
/**
|
|
273
|
+
* Clear all data from storage
|
|
274
|
+
*/
|
|
275
|
+
clear(): Promise<void>;
|
|
276
|
+
/**
|
|
277
|
+
* Get storage status
|
|
278
|
+
*/
|
|
279
|
+
getStorageStatus(): Promise<{
|
|
280
|
+
type: string;
|
|
281
|
+
used: number;
|
|
282
|
+
quota: number | null;
|
|
283
|
+
details?: Record<string, any>;
|
|
284
|
+
}>;
|
|
285
|
+
/**
|
|
286
|
+
* Save statistics data to storage
|
|
287
|
+
*/
|
|
288
|
+
protected saveStatisticsData(statistics: StatisticsData): Promise<void>;
|
|
289
|
+
/**
|
|
290
|
+
* Get statistics data from storage
|
|
291
|
+
*/
|
|
292
|
+
protected getStatisticsData(): Promise<StatisticsData | null>;
|
|
293
|
+
/**
|
|
294
|
+
* Initialize counts from storage
|
|
295
|
+
*/
|
|
296
|
+
protected initializeCounts(): Promise<void>;
|
|
297
|
+
/**
|
|
298
|
+
* Initialize counts from storage scan (expensive - only for first-time init)
|
|
299
|
+
*/
|
|
300
|
+
private initializeCountsFromScan;
|
|
301
|
+
/**
|
|
302
|
+
* Persist counts to storage
|
|
303
|
+
*/
|
|
304
|
+
protected persistCounts(): Promise<void>;
|
|
305
|
+
/**
|
|
306
|
+
* Get a noun's vector for HNSW rebuild
|
|
307
|
+
*/
|
|
308
|
+
getNounVector(id: string): Promise<number[] | null>;
|
|
309
|
+
/**
|
|
310
|
+
* Save HNSW graph data for a noun
|
|
311
|
+
*/
|
|
312
|
+
saveHNSWData(nounId: string, hnswData: {
|
|
313
|
+
level: number;
|
|
314
|
+
connections: Record<string, string[]>;
|
|
315
|
+
}): Promise<void>;
|
|
316
|
+
/**
|
|
317
|
+
* Get HNSW graph data for a noun
|
|
318
|
+
*/
|
|
319
|
+
getHNSWData(nounId: string): Promise<{
|
|
320
|
+
level: number;
|
|
321
|
+
connections: Record<string, string[]>;
|
|
322
|
+
} | null>;
|
|
323
|
+
/**
|
|
324
|
+
* Save HNSW system data (entry point, max level)
|
|
325
|
+
*/
|
|
326
|
+
saveHNSWSystem(systemData: {
|
|
327
|
+
entryPointId: string | null;
|
|
328
|
+
maxLevel: number;
|
|
329
|
+
}): Promise<void>;
|
|
330
|
+
/**
|
|
331
|
+
* Get HNSW system data (entry point, max level)
|
|
332
|
+
*/
|
|
333
|
+
getHNSWSystem(): Promise<{
|
|
334
|
+
entryPointId: string | null;
|
|
335
|
+
maxLevel: number;
|
|
336
|
+
} | null>;
|
|
337
|
+
/**
|
|
338
|
+
* Set the access tier for a specific blob (v4.0.0 cost optimization)
|
|
339
|
+
* Azure Blob Storage tiers:
|
|
340
|
+
* - Hot: $0.0184/GB/month - Frequently accessed data
|
|
341
|
+
* - Cool: $0.01/GB/month - Infrequently accessed data (45% cheaper)
|
|
342
|
+
* - Archive: $0.00099/GB/month - Rarely accessed data (99% cheaper!)
|
|
343
|
+
*
|
|
344
|
+
* @param blobName - Name of the blob to change tier
|
|
345
|
+
* @param tier - Target access tier ('Hot', 'Cool', or 'Archive')
|
|
346
|
+
* @returns Promise that resolves when tier is set
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* // Move old vectors to Archive tier (99% cost savings)
|
|
350
|
+
* await storage.setBlobTier('entities/nouns/vectors/ab/old-id.json', 'Archive')
|
|
351
|
+
*/
|
|
352
|
+
setBlobTier(blobName: string, tier: 'Hot' | 'Cool' | 'Archive'): Promise<void>;
|
|
353
|
+
/**
|
|
354
|
+
* Get the current access tier for a blob
|
|
355
|
+
*
|
|
356
|
+
* @param blobName - Name of the blob
|
|
357
|
+
* @returns Promise that resolves to the current tier or null if not found
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* const tier = await storage.getBlobTier('entities/nouns/vectors/ab/id.json')
|
|
361
|
+
* console.log(`Current tier: ${tier}`) // 'Hot', 'Cool', or 'Archive'
|
|
362
|
+
*/
|
|
363
|
+
getBlobTier(blobName: string): Promise<string | null>;
|
|
364
|
+
/**
|
|
365
|
+
* Set access tier for multiple blobs in batch (v4.0.0 cost optimization)
|
|
366
|
+
* Efficiently move large numbers of blobs between tiers for cost optimization
|
|
367
|
+
*
|
|
368
|
+
* @param blobs - Array of blob names and their target tiers
|
|
369
|
+
* @param options - Configuration options
|
|
370
|
+
* @returns Promise with statistics about tier changes
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* // Move old data to Archive tier for 99% cost savings
|
|
374
|
+
* const oldBlobs = await storage.listObjectsUnderPath('entities/nouns/vectors/')
|
|
375
|
+
* await storage.setBlobTierBatch(
|
|
376
|
+
* oldBlobs.map(name => ({ blobName: name, tier: 'Archive' }))
|
|
377
|
+
* )
|
|
378
|
+
*/
|
|
379
|
+
setBlobTierBatch(blobs: Array<{
|
|
380
|
+
blobName: string;
|
|
381
|
+
tier: 'Hot' | 'Cool' | 'Archive';
|
|
382
|
+
}>, options?: {
|
|
383
|
+
maxRetries?: number;
|
|
384
|
+
retryDelayMs?: number;
|
|
385
|
+
continueOnError?: boolean;
|
|
386
|
+
}): Promise<{
|
|
387
|
+
totalRequested: number;
|
|
388
|
+
successfulChanges: number;
|
|
389
|
+
failedChanges: number;
|
|
390
|
+
errors: Array<{
|
|
391
|
+
blobName: string;
|
|
392
|
+
error: string;
|
|
393
|
+
}>;
|
|
394
|
+
}>;
|
|
395
|
+
/**
|
|
396
|
+
* Check if a blob in Archive tier has been rehydrated and is ready to read
|
|
397
|
+
* Archive tier blobs must be rehydrated before they can be read
|
|
398
|
+
*
|
|
399
|
+
* @param blobName - Name of the blob to check
|
|
400
|
+
* @returns Promise that resolves to rehydration status
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* const status = await storage.checkRehydrationStatus('entities/nouns/vectors/ab/id.json')
|
|
404
|
+
* if (status.isRehydrated) {
|
|
405
|
+
* // Blob is ready to read
|
|
406
|
+
* const data = await storage.readObjectFromPath('entities/nouns/vectors/ab/id.json')
|
|
407
|
+
* }
|
|
408
|
+
*/
|
|
409
|
+
checkRehydrationStatus(blobName: string): Promise<{
|
|
410
|
+
isArchived: boolean;
|
|
411
|
+
isRehydrating: boolean;
|
|
412
|
+
isRehydrated: boolean;
|
|
413
|
+
rehydratePriority?: string;
|
|
414
|
+
}>;
|
|
415
|
+
/**
|
|
416
|
+
* Rehydrate an archived blob (move from Archive to Hot or Cool tier)
|
|
417
|
+
* Note: Rehydration can take several hours depending on priority
|
|
418
|
+
*
|
|
419
|
+
* @param blobName - Name of the blob to rehydrate
|
|
420
|
+
* @param targetTier - Target tier after rehydration ('Hot' or 'Cool')
|
|
421
|
+
* @param priority - Rehydration priority ('Standard' or 'High')
|
|
422
|
+
* Standard: Up to 15 hours, cheaper
|
|
423
|
+
* High: Up to 1 hour, more expensive
|
|
424
|
+
* @returns Promise that resolves when rehydration is initiated
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* // Rehydrate with standard priority (cheaper, slower)
|
|
428
|
+
* await storage.rehydrateBlob('entities/nouns/vectors/ab/id.json', 'Cool', 'Standard')
|
|
429
|
+
*
|
|
430
|
+
* // Check status
|
|
431
|
+
* const status = await storage.checkRehydrationStatus('entities/nouns/vectors/ab/id.json')
|
|
432
|
+
* console.log(`Rehydrating: ${status.isRehydrating}`)
|
|
433
|
+
*/
|
|
434
|
+
rehydrateBlob(blobName: string, targetTier: 'Hot' | 'Cool', priority?: 'Standard' | 'High'): Promise<void>;
|
|
435
|
+
/**
|
|
436
|
+
* Set lifecycle management policy for automatic tier transitions and deletions (v4.0.0)
|
|
437
|
+
* Automates cost optimization by moving old data to cheaper tiers or deleting it
|
|
438
|
+
*
|
|
439
|
+
* Azure Lifecycle Management rules run once per day and apply to the entire container.
|
|
440
|
+
* Rules are evaluated against blob properties like lastModifiedTime and lastAccessTime.
|
|
441
|
+
*
|
|
442
|
+
* @param options - Lifecycle policy configuration
|
|
443
|
+
* @returns Promise that resolves when policy is set
|
|
444
|
+
*
|
|
445
|
+
* @example
|
|
446
|
+
* // Auto-archive old vectors for 99% cost savings
|
|
447
|
+
* await storage.setLifecyclePolicy({
|
|
448
|
+
* rules: [
|
|
449
|
+
* {
|
|
450
|
+
* name: 'archiveOldVectors',
|
|
451
|
+
* enabled: true,
|
|
452
|
+
* type: 'Lifecycle',
|
|
453
|
+
* definition: {
|
|
454
|
+
* filters: {
|
|
455
|
+
* blobTypes: ['blockBlob'],
|
|
456
|
+
* prefixMatch: ['entities/nouns/vectors/']
|
|
457
|
+
* },
|
|
458
|
+
* actions: {
|
|
459
|
+
* baseBlob: {
|
|
460
|
+
* tierToCool: { daysAfterModificationGreaterThan: 30 },
|
|
461
|
+
* tierToArchive: { daysAfterModificationGreaterThan: 90 },
|
|
462
|
+
* delete: { daysAfterModificationGreaterThan: 365 }
|
|
463
|
+
* }
|
|
464
|
+
* }
|
|
465
|
+
* }
|
|
466
|
+
* }
|
|
467
|
+
* ]
|
|
468
|
+
* })
|
|
469
|
+
*/
|
|
470
|
+
setLifecyclePolicy(options: {
|
|
471
|
+
rules: Array<{
|
|
472
|
+
name: string;
|
|
473
|
+
enabled: boolean;
|
|
474
|
+
type: 'Lifecycle';
|
|
475
|
+
definition: {
|
|
476
|
+
filters: {
|
|
477
|
+
blobTypes: string[];
|
|
478
|
+
prefixMatch?: string[];
|
|
479
|
+
};
|
|
480
|
+
actions: {
|
|
481
|
+
baseBlob: {
|
|
482
|
+
tierToCool?: {
|
|
483
|
+
daysAfterModificationGreaterThan: number;
|
|
484
|
+
};
|
|
485
|
+
tierToArchive?: {
|
|
486
|
+
daysAfterModificationGreaterThan: number;
|
|
487
|
+
};
|
|
488
|
+
delete?: {
|
|
489
|
+
daysAfterModificationGreaterThan: number;
|
|
490
|
+
};
|
|
491
|
+
};
|
|
492
|
+
};
|
|
493
|
+
};
|
|
494
|
+
}>;
|
|
495
|
+
}): Promise<void>;
|
|
496
|
+
/**
|
|
497
|
+
* Get the current lifecycle management policy
|
|
498
|
+
*
|
|
499
|
+
* @returns Promise that resolves to the current policy or null if not set
|
|
500
|
+
*
|
|
501
|
+
* @example
|
|
502
|
+
* const policy = await storage.getLifecyclePolicy()
|
|
503
|
+
* if (policy) {
|
|
504
|
+
* console.log(`Found ${policy.rules.length} lifecycle rules`)
|
|
505
|
+
* }
|
|
506
|
+
*/
|
|
507
|
+
getLifecyclePolicy(): Promise<{
|
|
508
|
+
rules: Array<{
|
|
509
|
+
name: string;
|
|
510
|
+
enabled: boolean;
|
|
511
|
+
type: string;
|
|
512
|
+
definition: {
|
|
513
|
+
filters: {
|
|
514
|
+
blobTypes: string[];
|
|
515
|
+
prefixMatch?: string[];
|
|
516
|
+
};
|
|
517
|
+
actions: {
|
|
518
|
+
baseBlob: {
|
|
519
|
+
tierToCool?: {
|
|
520
|
+
daysAfterModificationGreaterThan: number;
|
|
521
|
+
};
|
|
522
|
+
tierToArchive?: {
|
|
523
|
+
daysAfterModificationGreaterThan: number;
|
|
524
|
+
};
|
|
525
|
+
delete?: {
|
|
526
|
+
daysAfterModificationGreaterThan: number;
|
|
527
|
+
};
|
|
528
|
+
};
|
|
529
|
+
};
|
|
530
|
+
};
|
|
531
|
+
}>;
|
|
532
|
+
} | null>;
|
|
533
|
+
/**
|
|
534
|
+
* Remove the lifecycle management policy
|
|
535
|
+
* All automatic tier transitions and deletions will stop
|
|
536
|
+
*
|
|
537
|
+
* @returns Promise that resolves when policy is removed
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* await storage.removeLifecyclePolicy()
|
|
541
|
+
* console.log('Lifecycle policy removed - auto-archival disabled')
|
|
542
|
+
*/
|
|
543
|
+
removeLifecyclePolicy(): Promise<void>;
|
|
544
|
+
}
|
|
545
|
+
export {};
|