{"_id":"@aizigao/pi-fetch-pipeline","_rev":"2-c7dd6a82b72ec400fb8d32c985b267ff","name":"@aizigao/pi-fetch-pipeline","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@aizigao/pi-fetch-pipeline","version":"1.0.0","keywords":["pi-package","pi-extension","fetch","middleware","pipeline"],"license":"MIT","_id":"@aizigao/pi-fetch-pipeline@1.0.0","maintainers":[{"name":"aizigao","email":"weixiangzhe@live.com"}],"homepage":"https://github.com/aizigao/pi-fetch-pipeline#readme","bugs":{"url":"https://github.com/aizigao/pi-fetch-pipeline/issues"},"dist":{"shasum":"f672baa25e9266181630d488f71cc7cb64ddedf4","tarball":"https://registry.npmjs.org/@aizigao/pi-fetch-pipeline/-/pi-fetch-pipeline-1.0.0.tgz","fileCount":5,"integrity":"sha512-+u2X70JGHQRHwUvq3L5uCYKzbHxQdNBrV8F+2KKr4fklFxFLRJ8bY7iK19OFX2PL4e9ds3gx8EEW+tHNeWmzng==","signatures":[{"sig":"MEUCIQCHeegC7PcBm8U4U/Izd1F7lISdWzvwqn8RNVpkqQEfKQIgUEzzDxX+TFNkrO92zOUB979BhPEXc5sNnpF9ZjE2Jpo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7214},"type":"module","engines":{"node":">=20"},"exports":{".":"./index.ts"},"gitHead":"cdb9c3fd454277b1d577ae42567ea83dc6176634","scripts":{"lint":"eslint .","check":"tsc --noEmit","lint:fix":"eslint . --fix"},"_npmUser":{"name":"aizigao","email":"weixiangzhe@live.com"},"repository":{"url":"git+https://github.com/aizigao/pi-fetch-pipeline.git","type":"git"},"_npmVersion":"10.9.4","description":"Shared fetch middleware pipeline for Pi extensions.","directories":{},"_nodeVersion":"22.21.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.39.1","@eslint/js":"^9.39.1","typescript":"^5.9.3","@types/node":"^24.10.1","typescript-eslint":"^8.46.4"},"_npmOperationalInternal":{"tmp":"tmp/pi-fetch-pipeline_1.0.0_1780220639675_0.8613301496517589","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@aizigao/pi-fetch-pipeline","version":"1.0.1","description":"Shared fetch middleware pipeline for Pi extensions.","type":"module","license":"MIT","homepage":"https://github.com/aizigao/pi-fetch-pipeline#readme","repository":{"type":"git","url":"git+https://github.com/aizigao/pi-fetch-pipeline.git"},"bugs":{"url":"https://github.com/aizigao/pi-fetch-pipeline/issues"},"keywords":["pi-extension","fetch","middleware","pipeline"],"engines":{"node":">=20"},"publishConfig":{"access":"public"},"scripts":{"check":"tsc --noEmit","lint":"eslint .","lint:fix":"eslint . --fix"},"exports":{".":"./index.ts"},"devDependencies":{"@eslint/js":"^9.39.1","@types/node":"^24.10.1","eslint":"^9.39.1","typescript":"^5.9.3","typescript-eslint":"^8.46.4"},"_id":"@aizigao/pi-fetch-pipeline@1.0.1","gitHead":"85e485b0e21b5d0cb5c40ca2c01eeaec7e4e98b1","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-xrK3gf5eDWiO+qomeNpWKyU6c8D6K/69EUc7xEZlbc7AJKPChcLyhOZPFIuIH/UkCOK/2btv7Swo55wA2yZwtQ==","shasum":"e8f39388305b976f0eb7c09701270c76e41f4511","tarball":"https://registry.npmjs.org/@aizigao/pi-fetch-pipeline/-/pi-fetch-pipeline-1.0.1.tgz","fileCount":5,"unpackedSize":7197,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEREDur0iX6nk16tK+RTSZHUxt2w8lMG4XBt7J+v62rmAiEAx/VYOnQGdi3G7CsNLnDOSZaV/NTC6r+ovBiZ6WJgkjk="}]},"_npmUser":{"name":"aizigao","email":"weixiangzhe@live.com"},"directories":{},"maintainers":[{"name":"aizigao","email":"weixiangzhe@live.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pi-fetch-pipeline_1.0.1_1780293266067_0.5878976106091125"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-31T09:43:59.562Z","modified":"2026-06-01T05:54:26.318Z","1.0.0":"2026-05-31T09:43:59.835Z","1.0.1":"2026-06-01T05:54:26.203Z"},"bugs":{"url":"https://github.com/aizigao/pi-fetch-pipeline/issues"},"license":"MIT","homepage":"https://github.com/aizigao/pi-fetch-pipeline#readme","keywords":["pi-extension","fetch","middleware","pipeline"],"repository":{"type":"git","url":"git+https://github.com/aizigao/pi-fetch-pipeline.git"},"description":"Shared fetch middleware pipeline for Pi extensions.","maintainers":[{"name":"aizigao","email":"weixiangzhe@live.com"}],"readme":"# @aizigao/pi-fetch-pipeline\n\nA tiny shared fetch middleware pipeline for Pi extensions.\n\n## Why\n\nMultiple Pi extensions sometimes patch `globalThis.fetch` independently:\n\n- proxy routing\n- header rewriting\n- cookie injection\n- URL rewriting\n- provider compatibility shims\n\nIf each extension patches `fetch` on its own, the last one loaded usually wins, or some requests bypass other extensions entirely.\n\n`@aizigao/pi-fetch-pipeline` solves this by providing a shared global pipeline keyed by:\n\n```ts\nSymbol.for(\"aizigao.fetch.pipeline.v1\")\n```\n\nExtensions can be installed independently and still compose safely.\n\n## Install\n\n```bash\nnpm install @aizigao/pi-fetch-pipeline\n```\n\n## Usage\n\n```ts\nimport { registerFetchMiddleware } from \"@aizigao/pi-fetch-pipeline\";\n\nregisterFetchMiddleware({\n  name: \"headers-compat\",\n  priority: 10,\n  middleware: async ({ input, init, next }) => {\n    const headers = new Headers(init?.headers);\n    headers.set(\"x-demo\", \"1\");\n    return next(input, { ...init, headers });\n  },\n});\n```\n\n## Ordering\n\nMiddlewares are executed by ascending `priority`.\n\nSuggested convention:\n\n- `10`: request/header compatibility rewrites\n- `20`: provider-specific host tweaks\n- `50`: proxy / transport routing\n\n## API\n\n### `registerFetchMiddleware(registration)`\n\nRegisters or replaces a named middleware and ensures the shared pipeline is installed.\n\n### `ensureFetchPipeline()`\n\nCreates the shared pipeline state if missing and returns it.\n\n### `installFetchPipeline()`\n\nInstalls the patched `globalThis.fetch` if not already installed.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}