{"_id":"@affectively/utils","_rev":"4-ea65e00703e6fec87056afdf0c8627a2","name":"@affectively/utils","dist-tags":{"latest":"5.0.0"},"versions":{"1.0.0":{"name":"@affectively/utils","version":"1.0.0","keywords":["utilities","api-retry","logger","url-shortener","typescript","fetch","authentication"],"author":{"name":"AFFECTIVELY","email":"opensource@affectively.app"},"license":"MIT","_id":"@affectively/utils@1.0.0","maintainers":[{"name":"buley","email":"buley@outlook.com"}],"homepage":"https://github.com/affectively-ai/utils#readme","bugs":{"url":"https://github.com/affectively-ai/utils/issues"},"dist":{"shasum":"a3026dc14e8673da08e6461d81610b110301728b","tarball":"https://registry.npmjs.org/@affectively/utils/-/utils-1.0.0.tgz","fileCount":23,"integrity":"sha512-jeTUadoRVXgJVYzxw2DdCUFZkpx9M5Zh460vReUOueVQliChFeJ6C9/mPIp/qac5MLQ8TghxiEKcho1smM7aXw==","signatures":[{"sig":"MEUCIQCk1sCBz0Ia16Li1satuW7zixmCjM4ueI0oPUVxPDRfbAIgAwoQDX1GrxYvVDWimF3c5HWGJXFngoGgxfxFSpVkL7I=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35967},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./logger":{"types":"./dist/logger.d.ts","import":"./dist/logger.mjs","require":"./dist/logger.js"},"./api-retry":{"types":"./dist/api-retry.d.ts","import":"./dist/api-retry.mjs","require":"./dist/api-retry.js"},"./short-url":{"types":"./dist/short-url.d.ts","import":"./dist/short-url.mjs","require":"./dist/short-url.js"}},"gitHead":"62896cc18e2ed24e5a949caff4310924cd29e822","scripts":{"lint":"eslint src/","test":"bun test","build":"tsup src/index.ts src/api-retry.ts src/logger.ts src/short-url.ts --format cjs,esm --dts","prepublishOnly":"npm run build"},"_npmUser":{"name":"buley","email":"buley@outlook.com"},"repository":{"url":"git+https://github.com/affectively-ai/utils.git","type":"git"},"_npmVersion":"11.6.2","description":"TypeScript utility functions for API retry, logging, URL shortening, and more.","directories":{},"_nodeVersion":"24.11.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.9.0"},"_npmOperationalInternal":{"tmp":"tmp/utils_1.0.0_1768339309341_0.9889647649240128","host":"s3://npm-registry-packages-npm-production"},"deprecated":"This package is deprecated and no longer supported. Do not use."},"1.0.1":{"name":"@affectively/utils","version":"1.0.1","keywords":["utilities","api-retry","logger","url-shortener","typescript","fetch","authentication"],"author":{"name":"AFFECTIVELY","email":"opensource@affectively.ai"},"license":"MIT","_id":"@affectively/utils@1.0.1","maintainers":[{"name":"buley","email":"buley@outlook.com"}],"homepage":"https://github.com/affectively-ai/utils#readme","bugs":{"url":"https://github.com/affectively-ai/utils/issues"},"dist":{"shasum":"f3ae1421e9225268c085d39a15bd03b07b39a60d","tarball":"https://registry.npmjs.org/@affectively/utils/-/utils-1.0.1.tgz","fileCount":23,"integrity":"sha512-YP3kcJSoYKD3PAGq1gZrxT6LJ+lpTHhbTnSWH+6x+IJgfrO3ucrgf15Mcb1OjBmZLWfQcVKnH+x37oJlx7Ofsw==","signatures":[{"sig":"MEUCIQC86ySPvwFvGwlZ3+MJTJPozylOMrsgZf2UQUsWjgs0PQIgXrfYN7lLb2xWcJcs8SNH6x94nsEbcxVlTm8gvo88gzs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35958},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./logger":{"types":"./dist/logger.d.ts","import":"./dist/logger.mjs","require":"./dist/logger.js"},"./api-retry":{"types":"./dist/api-retry.d.ts","import":"./dist/api-retry.mjs","require":"./dist/api-retry.js"},"./short-url":{"types":"./dist/short-url.d.ts","import":"./dist/short-url.mjs","require":"./dist/short-url.js"}},"gitHead":"629341c1b193cf91d7c960422583b13479fc8e7e","scripts":{"lint":"eslint src/","test":"bun test","build":"tsup src/index.ts src/api-retry.ts src/logger.ts src/short-url.ts --format cjs,esm --dts","prepublishOnly":"npm run build"},"_npmUser":{"name":"buley","email":"buley@outlook.com"},"repository":{"url":"git+https://github.com/affectively-ai/utils.git","type":"git"},"_npmVersion":"11.6.2","description":"TypeScript utility functions for API retry, logging, URL shortening, and more.","directories":{},"_nodeVersion":"24.11.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.9.0"},"_npmOperationalInternal":{"tmp":"tmp/utils_1.0.1_1768341060914_0.3727721413393832","host":"s3://npm-registry-packages-npm-production"},"deprecated":"This package is deprecated and no longer supported. Do not use."},"5.0.0":{"name":"@affectively/utils","version":"5.0.0","keywords":["utilities","api-retry","logger","url-shortener","typescript","fetch","authentication"],"author":{"url":"https://buley.fyi","name":"Taylor William Buley"},"license":"UNLICENSED","_id":"@affectively/utils@5.0.0","maintainers":[{"name":"buley","email":"buley@outlook.com"}],"homepage":"https://github.com/affectively-ai/utils#readme","bugs":{"url":"https://github.com/affectively-ai/utils/issues"},"dist":{"shasum":"4239fa375c44f705224bf6cbf00eed9f4524c733","tarball":"https://registry.npmjs.org/@affectively/utils/-/utils-5.0.0.tgz","fileCount":23,"integrity":"sha512-mHNUxbPhTLZQVLxivHKVlDMIpoD5OEYAMi0grt8ol82F7zTpWfMUCF5HysCBFVbdLB5alN636ssuL0lMP/3IWg==","signatures":[{"sig":"MEQCIFeTAt1Q4fT+Tf59UgR2LzmugZff6vtWnI/BHlDPD1XUAiBuPhaVBSFLCU37ICciMXGxAC3zT4DUUk5+Kmdghd0GIg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35671},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./logger":{"types":"./dist/logger.d.ts","import":"./dist/logger.mjs","require":"./dist/logger.js"},"./api-retry":{"types":"./dist/api-retry.d.ts","import":"./dist/api-retry.mjs","require":"./dist/api-retry.js"},"./short-url":{"types":"./dist/short-url.d.ts","import":"./dist/short-url.mjs","require":"./dist/short-url.js"}},"scripts":{"lint":"eslint src/","test":"bun test","build":"tsup src/index.ts src/api-retry.ts src/logger.ts src/short-url.ts --format cjs,esm --dts","prepublishOnly":"npm run build"},"_npmUser":{"name":"buley","email":"buley@outlook.com"},"repository":{"url":"git+https://github.com/affectively-ai/utils.git","type":"git"},"_npmVersion":"11.8.0","description":"TypeScript utility functions for API retry, logging, URL shortening, and more.","directories":{},"_nodeVersion":"25.5.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.9.0"},"_npmOperationalInternal":{"tmp":"tmp/utils_5.0.0_1773156287875_0.9295025965721639","host":"s3://npm-registry-packages-npm-production"},"deprecated":"This package is deprecated and no longer supported. Do not use."}},"time":{"created":"2026-01-13T21:21:49.188Z","modified":"2026-03-27T20:03:51.968Z","1.0.0":"2026-01-13T21:21:49.528Z","1.0.1":"2026-01-13T21:51:01.068Z","5.0.0":"2026-03-10T15:24:48.044Z"},"bugs":{"url":"https://github.com/affectively-ai/utils/issues"},"author":{"url":"https://buley.fyi","name":"Taylor William Buley"},"license":"UNLICENSED","homepage":"https://github.com/affectively-ai/utils#readme","keywords":["utilities","api-retry","logger","url-shortener","typescript","fetch","authentication"],"repository":{"url":"git+https://github.com/affectively-ai/utils.git","type":"git"},"description":"TypeScript utility functions for API retry, logging, URL shortening, and more.","maintainers":[{"name":"buley","email":"buley@outlook.com"}],"readme":"# @affectively/utils\r\n\r\nTypeScript utility functions for common development tasks.\r\n\r\n[![npm version](https://img.shields.io/npm/v/@affectively/utils.svg)](https://www.npmjs.com/package/@affectively/utils)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\r\n\r\n## Features\r\n\r\n- **API Retry** - Automatic retry with authentication token refresh\r\n- **Logger** - Simple, consistent logging utility\r\n- **Short URL** - Generate cryptographically secure short codes\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install @affectively/utils\r\n# or\r\nyarn add @affectively/utils\r\n# or\r\nbun add @affectively/utils\r\n```\r\n\r\n## Quick Start\r\n\r\n```typescript\r\nimport { fetchWithRetry, logger, generateShortCode } from '@affectively/utils';\r\n\r\n// API retry with auth\r\nconst response = await fetchWithRetry('/api/data', {\r\n method: 'GET'\r\n}, {\r\n maxRetries: 3,\r\n getToken: async () => localStorage.getItem('token')\r\n});\r\n\r\n// Logging\r\nlogger.info('Request completed', { status: response.status });\r\n\r\n// Short URL generation\r\nconst code = generateShortCode(); // e.g., \"xK9mN2pL\"\r\n```\r\n\r\n## API Reference\r\n\r\n### API Retry\r\n\r\nAutomatically retry failed API requests with token refresh.\r\n\r\n```typescript\r\nimport { fetchWithRetry, fetchJsonWithRetry } from '@affectively/utils/api-retry';\r\n\r\n// Basic retry\r\nconst response = await fetchWithRetry(url, options, {\r\n maxRetries: 2,\r\n getToken: async () => getAuthToken(),\r\n isAuthError: (response) => response.status === 401\r\n});\r\n\r\n// JSON retry with auto-parsing\r\nconst data = await fetchJsonWithRetry<MyType>(url, options, retryOptions);\r\n```\r\n\r\n### Logger\r\n\r\nSimple logging with consistent formatting.\r\n\r\n```typescript\r\nimport { logger } from '@affectively/utils/logger';\r\n\r\nlogger.debug('Debug message', { context: 'value' });\r\nlogger.info('Info message');\r\nlogger.warn('Warning message');\r\nlogger.error('Error message', error);\r\n```\r\n\r\n### Short URL\r\n\r\nGenerate cryptographically secure short codes.\r\n\r\n```typescript\r\nimport { generateShortCode, createShortUrl } from '@affectively/utils/short-url';\r\n\r\n// Generate 8-character base62 code\r\nconst code = generateShortCode(); // \"xK9mN2pL\"\r\n\r\n// Create full short URL\r\nconst url = createShortUrl(code, 'https://mysite.com'); // \"https://mysite.com/s/xK9mN2pL\"\r\n```\r\n\r\n## Tree-Shakeable Imports\r\n\r\nImport only what you need:\r\n\r\n```typescript\r\n// Import everything\r\nimport { fetchWithRetry, logger, generateShortCode } from '@affectively/utils';\r\n\r\n// Or import specific modules\r\nimport { fetchWithRetry } from '@affectively/utils/api-retry';\r\nimport { logger } from '@affectively/utils/logger';\r\nimport { generateShortCode } from '@affectively/utils/short-url';\r\n```\r\n\r\n## License\r\n\r\nMIT License - see [LICENSE](./LICENSE) for details.\r\n\r\n---\r\n\r\nMade with ️ by [AFFECTIVELY](https://affectively.ai)\r\n","readmeFilename":"README.md"}