Registry / storage / oc-storage-adapters-utils

oc-storage-adapters-utils

JSON →
library2.1.2jsnpmunverified

Utility library for building storage adapters in the OpenComponents (OC) ecosystem. Version 2.x provides shared utilities like hash computation, path manipulation, and caching helpers for OC storage backends (S3, Azure, local filesystem). Designed to reduce boilerplate across storage adapter packages. Requires Node.js 12+. Released as a dependency-focused utility, not a standalone adapter. Currently in maintenance mode for OC core compatibility. Differentiated by direct integration with OC's plugin container lifecycle.

npm install oc-storage-adapters-utils
INSTALL
IMPORT
SIG · OC-STORAGE-ADAPTER
O
oc-storage-adapters-utils
storagejavascriptv2.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

computeHash
import { computeHash } from 'oc-storage-adapters-utils'
const computeHash = require('oc-storage-adapters-utils').computeHash
ESM imports recommended; CJS require alternative works but may break in future versions.
getCacheStrategy
import { getCacheStrategy } from 'oc-storage-adapters-utils'
const getCacheStrategy = require('oc-storage-adapters-utils')
Only named export; default export does not exist.
sanitizePath
import { sanitizePath } from 'oc-storage-adapters-utils'
TS types included; no known wrong import patterns.

Demonstrates importing and using computeHash and sanitizePath utilities to handle OC component storage paths.

import { computeHash, sanitizePath } from 'oc-storage-adapters-utils'; import { CacheStrategy } from 'oc-storage-adapters'; const filePath = 'components/header/1.0.0/template.js'; const sanitized = sanitizePath(filePath); console.log('Sanitized:', sanitized); const hash = computeHash({ path: sanitized, strategy: CacheStrategy.STATIC }); console.log('Hash:', hash);
Debug
Known issues
gotchacomputeHash uses SHA-256 by default; ensure your storage adapter expects the same hash algorithm to avoid cache mismatches.
fix
Always verify hash algorithm compatibility with your storage backend.
affects: >=1.0.0
deprecatedThe library no longer exports 'legacyHash' in v2; use 'computeHash' instead.
fix
Replace legacyHash calls with computeHash and adjust parameters if needed.
affects: >=2.0.0
gotchasanitizePath does not URL-encode special characters; manual encoding may be required for cloud storage keys.
fix
Use encodeURIComponent on path segments if working with S3 or Azure Blob Storage.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: computeHash is not a function
Using default import instead of named import; library has no default export.
fix
Change to named import: import { computeHash } from 'oc-storage-adapters-utils'
Module not found: Can't resolve 'oc-storage-adapters'
Missing peer dependency oc-storage-adapters.
fix
Install peer dependency: npm install oc-storage-adapters
Upgrade
Version history
2.1.2latest on npm
Audit
Dependencies
oc-storage-adaptersrequiredProvides the base storage adapter interface
Agent activity
31 hits · last 30 days
node
26
Amazon
1
OpenAI (training)
1
Resources
oc-storage-adapters-utils — npm install oc-storage-adapters-utils · libregistry