braid-blob 0.0.39 → 0.0.41

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 (4) hide show
  1. package/AI-README.md +13 -32
  2. package/index.js +325 -320
  3. package/package.json +1 -1
  4. package/test/tests.js +199 -78
package/AI-README.md CHANGED
@@ -54,11 +54,6 @@ DEPENDENCY_UPDATES:
54
54
  - Format: "updates to {package}@{version}"
55
55
  - Example: "0.0.18 - ... updates to url-file-db 0.0.8"
56
56
 
57
- RESOLVED_ISSUES:
58
- - url-file-db < 0.0.13: Bug where reading non-existent files returned "index" file contents
59
- - Fixed in url-file-db 0.0.13+ (properly returns null for non-existent files)
60
- - Caused "test sync local to remote" to fail with unexpected "shared content"
61
- - url-file-db 0.0.15+ also relaxed path requirements (no longer requires leading "/")
62
57
  ```
63
58
 
64
59
  ## MODULE_STRUCTURE
@@ -67,7 +62,7 @@ RESOLVED_ISSUES:
67
62
  EXPORT: create_braid_blob() -> braid_blob_instance
68
63
  MODULE_TYPE: CommonJS
69
64
  MAIN_ENTRY: index.js
70
- DEPENDENCIES: [braid-http, url-file-db, fs, path]
65
+ DEPENDENCIES: [braid-http, fs]
71
66
  ```
72
67
 
73
68
  ## DATA_MODEL
@@ -81,9 +76,9 @@ braid_blob_instance = {
81
76
 
82
77
  // Runtime state
83
78
  cache: object // internal cache
79
+ meta_cache: object // metadata cache
84
80
  key_to_subs: Map<key, Map<peer, subscription>> // subscription tracking
85
- db: url_file_db_instance // blob storage backend
86
- meta_db: url_file_db_instance // metadata storage backend
81
+ db: {read, write, delete} // blob storage backend (auto-created or custom)
87
82
 
88
83
  // Methods
89
84
  init: async () -> void
@@ -130,6 +125,7 @@ INPUT:
130
125
  content_type?: string // MIME type
131
126
  peer?: string // peer identifier
132
127
  skip_write?: boolean // skip disk write (for external changes)
128
+ db?: {read, write, delete} // custom db backend (overrides braid_blob.db)
133
129
  signal?: AbortSignal // for URL mode
134
130
  headers?: object // for URL mode
135
131
  }
@@ -137,8 +133,8 @@ INPUT:
137
133
  OUTPUT: version_string
138
134
 
139
135
  SIDE_EFFECTS:
140
- - Writes blob to db_folder via url-file-db
141
- - Writes metadata to meta_folder/db
136
+ - Writes blob to db (options.db or braid_blob.db)
137
+ - Writes metadata to meta_folder
142
138
  - Notifies active subscriptions (except originating peer)
143
139
  - If key instanceof URL: makes remote HTTP PUT via braid_fetch
144
140
 
@@ -163,6 +159,7 @@ INPUT:
163
159
  parents?: [version] // fork-point for subscriptions
164
160
  version?: [version] // request specific version
165
161
  peer?: string // peer identifier
162
+ db?: {read, write, delete} // custom db backend (overrides braid_blob.db)
166
163
  signal?: AbortSignal // for URL mode
167
164
  dont_retry?: boolean // for URL mode subscriptions
168
165
  }
@@ -294,14 +291,11 @@ isAcceptable(contentType, acceptHeader) -> boolean
294
291
 
295
292
  ```
296
293
  db_folder/
297
- {url_file_db structure}
298
- - Blob data stored via url-file-db
299
- - Key mapping: URL-safe encoding of keys
294
+ {encoded_key} # Blob data files
295
+ - Key encoding: encode_filename() escapes special chars
300
296
 
301
297
  meta_folder/
302
- peer.txt # Peer ID (auto-generated if missing)
303
- db/ # url-file-db for metadata
304
- {encoded_key}.txt # JSON: {event: version, content_type: mime}
298
+ {encoded_key} # JSON metadata files: {event: version, content_type: mime}
305
299
  ```
306
300
 
307
301
  ## PROTOCOL_DETAILS
@@ -344,8 +338,8 @@ BRAID_UPDATE_FORMAT:
344
338
  INITIALIZATION:
345
339
  - init() called lazily by put/get/serve
346
340
  - init() runs once (subsequent calls return same promise)
347
- - Creates db and meta_db url-file-db instances
348
- - Loads or generates peer ID
341
+ - Creates db object with read/write/delete methods (or uses provided db_folder object)
342
+ - Generates peer ID if not set
349
343
 
350
344
  SUBSCRIPTION_MANAGEMENT:
351
345
  - key_to_subs: Map<string, Map<string, {sendUpdate}>>
@@ -354,11 +348,6 @@ SUBSCRIPTION_MANAGEMENT:
354
348
  - Prevents echo: put() doesn't notify originating peer
355
349
  - Serialized updates: subscribe_chain ensures sequential callback execution
356
350
 
357
- FILE_WATCHING:
358
- - url-file-db monitors db_folder for external changes
359
- - External changes trigger put() with skip_write: true
360
- - Subscriptions notified of external changes
361
-
362
351
  CONCURRENCY_CONTROL:
363
352
  - within_fiber(key, fn) serializes operations per key
364
353
  - Uses promise chain stored in within_fiber.chains[key]
@@ -413,14 +402,6 @@ braid-http:
413
402
  - http_server (braidify): Adds Braid protocol support to Node.js HTTP
414
403
  - fetch (braid_fetch): Braid-aware fetch implementation
415
404
  - Handles: Subscribe headers, Version headers, streaming updates
416
-
417
- url-file-db (^0.0.15):
418
- - Bidirectional URL ↔ filesystem mapping
419
- - Collision-resistant encoding (case-insensitive filesystem safe)
420
- - File watching for external changes
421
- - Separate instances for blobs (db) and metadata (meta_db)
422
- - API change in 0.0.15: use get_canonical_path() instead of url_path_to_canonical_path()
423
- - Fixed in 0.0.13+: properly returns null for non-existent files (not "index" content)
424
405
  ```
425
406
 
426
407
  ## ERROR_CONDITIONS
@@ -455,7 +436,7 @@ TEST_RUNNER: test/test.js
455
436
  - Browser mode: Opens puppeteer, loads test.html
456
437
 
457
438
  TEST_SUITE: test/tests.js
458
- - 40+ test cases covering:
439
+ - 50+ test cases covering:
459
440
  - Basic put/get operations
460
441
  - Subscriptions and updates
461
442
  - Version conflict resolution