{"_id":"@assetflux.io/sdk","name":"@assetflux.io/sdk","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@assetflux.io/sdk","version":"1.0.0","description":"TypeScript/Node.js SDK for AssetFlux — asset management, manifest fetching, and rollout support","license":"BSD-3-Clause","homepage":"https://docs.assetflux.io/typescript/","repository":{"type":"git","url":"git+https://github.com/Patryczon/AssetFlux.git","directory":"typescript_sdk"},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","clean":"rm -rf dist/"},"keywords":["assetflux","asset-management","remote-images","cdn","rollout","manifest","sdk"],"engines":{"node":">=18.0.0"},"devDependencies":{"@types/node":"^20.0.0","typescript":"^5.5.0"},"_id":"@assetflux.io/sdk@1.0.0","gitHead":"004127b48a6fbe16d4e58d59c78941d20145affc","bugs":{"url":"https://github.com/Patryczon/AssetFlux/issues"},"_nodeVersion":"22.16.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-ppt1kE/1cvVMPc0KnNhlC+Xy6KsfAJjM+6wIKXwiYm/tEhuDKsgWrztPi62IxkTGvsl2gVgQYuNTJ3Na357alw==","shasum":"c13df86b95d00e24528d4b4bf5b4caee5e011cbb","tarball":"https://registry.npmjs.org/@assetflux.io/sdk/-/sdk-1.0.0.tgz","fileCount":32,"unpackedSize":122672,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIH+WoBnmfrG4jSDIs8ESS/StTpnmlFKef17DlQ63oZPiAiAfOyK9GzHRkDXlqrPtT8rkUfW5udjPynMPWyky1ElcXA=="}]},"_npmUser":{"name":"assetflux","email":"support@assetflux.io"},"directories":{},"maintainers":[{"name":"assetflux","email":"support@assetflux.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_1.0.0_1770806954222_0.16080533620895543"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-11T10:49:14.115Z","1.0.0":"2026-02-11T10:49:14.371Z","modified":"2026-02-11T10:49:14.627Z"},"maintainers":[{"name":"assetflux","email":"support@assetflux.io"}],"description":"TypeScript/Node.js SDK for AssetFlux — asset management, manifest fetching, and rollout support","homepage":"https://docs.assetflux.io/typescript/","keywords":["assetflux","asset-management","remote-images","cdn","rollout","manifest","sdk"],"repository":{"type":"git","url":"git+https://github.com/Patryczon/AssetFlux.git","directory":"typescript_sdk"},"bugs":{"url":"https://github.com/Patryczon/AssetFlux/issues"},"license":"BSD-3-Clause","readme":"# AssetFlux TypeScript SDK\n\n[![npm version](https://img.shields.io/npm/v/@assetflux.io/sdk.svg)](https://www.npmjs.com/package/@assetflux.io/sdk)\n[![License: BSD-3-Clause](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)\n\nServer-side TypeScript/Node.js SDK for [AssetFlux](https://assetflux.io). Fetch asset manifests, resolve CDN URLs, and manage gradual rollouts in your Node.js applications, SSR frameworks, or build pipelines.\n\n## Getting Started\n\n### 1. Install\n\n```bash\nnpm install @assetflux.io/sdk\n```\n\n### 2. Initialize\n\n```ts\nimport { AssetFlux } from '@assetflux.io/sdk';\n\nconst result = await AssetFlux.init({\n  projectId: 'af_your_project_id',\n  apiKey: 'afk_your_sdk_key',\n});\n\nconsole.log(`Environment: ${result.environment}`);\n```\n\n### 3. Access the Manifest\n\n```ts\nconst manifest = AssetFlux.getManifest();\n\nfor (const asset of manifest.assets) {\n  console.log(`${asset.key}: ${asset.cdnUrl}`);\n}\n```\n\n## Usage\n\n### Get Manifest and Assets\n\n```ts\nconst manifest = AssetFlux.getManifest();\nconst asset = manifest?.assets.find(a => a.key === 'home.hero.banner');\n\nif (asset) {\n  console.log(asset.cdnUrl);      // CDN URL for the active version\n  console.log(asset.version.id);  // Version identifier\n  console.log(asset.rollout);     // { percentage: 100 }\n}\n```\n\n### Force Refresh\n\n```ts\nconst updated = await AssetFlux.refreshManifest();\nconsole.log(`Refreshed: ${updated.assets.length} assets`);\n```\n\n### Cache Statistics\n\n```ts\nconst stats = AssetFlux.getManifestCacheStats();\nconsole.log(stats);\n// { hasCachedManifest: true, isExpired: false, ttlRemaining: 285000, assetCount: 12, ... }\n```\n\n### Rollout Assignment\n\n```ts\n// Check if current device is in a rollout\nconst inRollout = AssetFlux.isInRollout(50); // 50% rollout\nconsole.log(`In rollout: ${inRollout}`);\n\n// Get full rollout details\nconst assignment = AssetFlux.getRolloutAssignment(25);\nconsole.log(assignment);\n// { identifier: '...', bucket: 42, isInRollout: false }\n\n// Check specific asset rollout\nconst assetInRollout = AssetFlux.isAssetInRollout('home.hero.banner');\n```\n\n### User-Based Rollout\n\n```ts\nawait AssetFlux.init({\n  projectId: 'af_...',\n  apiKey: 'afk_...',\n  config: {\n    identifierType: 'user',\n  },\n});\n\n// After user login\nAssetFlux.setUserId('user_12345');\n```\n\n### Custom HTTP Client\n\n```ts\nimport { AssetFluxSDK, HttpClient } from '@assetflux.io/sdk';\n\nconst customClient: HttpClient = {\n  async get(url, options) {\n    const res = await myHttpLib.get(url, { headers: options?.headers });\n    return { status: res.statusCode, data: res.body };\n  },\n};\n\nconst sdk = new AssetFluxSDK(customClient);\nawait sdk.init({ projectId: 'af_...', apiKey: 'afk_...' });\n```\n\n## Configuration\n\n```ts\nawait AssetFlux.init({\n  projectId: 'af_...',\n  apiKey: 'afk_...',\n  config: {\n    baseUrl: 'https://api.assetflux.io',   // API base URL\n    cacheTTL: 300_000,                       // 5 minutes\n    timeout: 10_000,                         // 10 seconds\n    retryAttempts: 3,\n    fallbackBehavior: 'cache',               // 'cache' | 'bundled' | 'error'\n    identifierType: 'device',                // 'device' | 'user' | 'custom'\n    backgroundRefresh: true,\n    refreshInterval: 900_000,                // 15 minutes\n    cacheDirectory: '/tmp/assetflux-cache',  // disk cache location\n    debug: false,\n  },\n});\n```\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `baseUrl` | `string` | `https://api.assetflux.io` | API base URL |\n| `cacheTTL` | `number` | `300000` (5m) | Manifest cache TTL in ms |\n| `timeout` | `number` | `10000` (10s) | Network request timeout in ms |\n| `retryAttempts` | `number` | `3` | Max retry attempts with exponential backoff |\n| `fallbackBehavior` | `string` | `cache` | Behavior when offline: `cache`, `bundled`, or `error` |\n| `identifierType` | `string` | `device` | Identifier for rollout: `device`, `user`, or `custom` |\n| `backgroundRefresh` | `boolean` | `true` | Enable background manifest refresh |\n| `refreshInterval` | `number` | `900000` (15m) | Background refresh interval in ms |\n| `cacheDirectory` | `string?` | OS default | Directory for disk-based manifest cache |\n| `debug` | `boolean` | `false` | Enable debug logging |\n\n## Requirements\n\n- Node.js >= 18.0\n\n## Documentation\n\nFull documentation is available at **[docs.assetflux.io/typescript](https://docs.assetflux.io/typescript/)**.\n\n## License\n\nBSD 3-Clause. See [LICENSE](LICENSE) for details.\n","readmeFilename":"README.md","_rev":"1-b0da50f3fd97294566cc676d37d46342"}