{"_id":"@adaskothebeast/http-params-processor-key-flat","_rev":"4-07b8a8a5f9173345fc000ffc852a4551","name":"@adaskothebeast/http-params-processor-key-flat","dist-tags":{"latest":"12.0.0"},"versions":{"10.0.0":{"name":"@adaskothebeast/http-params-processor-key-flat","version":"10.0.0","_id":"@adaskothebeast/http-params-processor-key-flat@10.0.0","maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"dist":{"shasum":"809cf4e32d10f6a7b98e95d53078cd8629d5e4f6","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-key-flat/-/http-params-processor-key-flat-10.0.0.tgz","fileCount":15,"integrity":"sha512-VOM82dOrSMN7TNAIAaTjq9J1zWEQast4JlXcd4DsNB5B/NniYqgTIO66ZnocjapgNL27Y22VXuFihmYQ0Cvedg==","signatures":[{"sig":"MEQCIGZJn6WsZlpzDEU/XTLOySDNIhKGWZDli0RHEKfo59vhAiBdgZKxBl5ezFZci+wY5ze5gPHCrtTyZwefZOdwcgX+ng==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":28045},"main":"./src/index.js","type":"commonjs","types":"./src/index.d.ts","gitHead":"1e61d6323f67038b9af916e4f3d263a73fe76497","_npmUser":{"name":"adasko","email":"adaskothebeast@gmail.com"},"_npmVersion":"11.6.2","description":"> Transform complex TypeScript objects into query parameters for Angular, Axios, Fetch, and more","directories":{},"sideEffects":false,"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"peerDependencies":{"@adaskothebeast/http-params-processor-core":"^10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/http-params-processor-key-flat_10.0.0_1768077141819_0.8144525117679282","host":"s3://npm-registry-packages-npm-production"}},"11.0.0":{"name":"@adaskothebeast/http-params-processor-key-flat","version":"11.0.0","author":{"url":"https://github.com/adaskothebeast","name":"Adam Pluciński","email":"adaskothebeast@gmail.com"},"license":"MIT","_id":"@adaskothebeast/http-params-processor-key-flat@11.0.0","maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"dist":{"shasum":"ae500e1919ba4574b9c030fbdc5866d1c1dafc80","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-key-flat/-/http-params-processor-key-flat-11.0.0.tgz","fileCount":8,"integrity":"sha512-Tc9l/sAuJGmo5lgzuWwHy7MeRggGmarG4rCPzg8bq9oqbbvrkEzniYvBN1P0mFj/goZ/9OLwO0AdWcTjXiFrkg==","signatures":[{"sig":"MEYCIQDvXCJJQiHZdV8k0cdsDPXdJqBJBfS8bYm4RVT57FdoaAIhAJCTtbdb4fl6aXOq/DduFJjCR/quk82wmDdGAbxXJRsn","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaskothebeast%2fhttp-params-processor-key-flat@11.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":39157},"main":"./index.cjs","type":"module","types":"./index.d.ts","module":"./index.js","exports":{".":{"types":"./index.d.ts","import":"./index.js","default":"./index.js","require":"./index.cjs"},"./package.json":"./package.json"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:96304087-c1f3-4da4-ac91-2caf5b73a57e"}},"repository":{"url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git","type":"git"},"_npmVersion":"11.6.2","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/http-params-processor-key-flat_11.0.0_1768758175498_0.7526498270557025","host":"s3://npm-registry-packages-npm-production"}},"11.1.0":{"name":"@adaskothebeast/http-params-processor-key-flat","version":"11.1.0","author":{"url":"https://github.com/adaskothebeast","name":"Adam Pluciński","email":"adaskothebeast@gmail.com"},"license":"MIT","_id":"@adaskothebeast/http-params-processor-key-flat@11.1.0","maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"dist":{"shasum":"250b6cc503046f4176469b9c5abc640600e17744","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-key-flat/-/http-params-processor-key-flat-11.1.0.tgz","fileCount":8,"integrity":"sha512-zFcswLh8f4Ae1qLthg9Qd67ErDmuoy75sWizr9L9Zx1lc2M7/M0e3mkuklXF/Yyk1meYV/KnnNBJaC2q8rizUQ==","signatures":[{"sig":"MEQCIHzoFb+zFA/5NKNBNDTQsXBmhrvDxsPPwaKJEsiGyG9NAiAs+YhRVgOiaU0Rkdv3CugqVrjHE5xpwTS5WUrPC46L1A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaskothebeast%2fhttp-params-processor-key-flat@11.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":39157},"main":"./index.cjs","type":"module","types":"./index.d.ts","module":"./index.js","exports":{".":{"types":"./index.d.ts","import":"./index.js","default":"./index.js","require":"./index.cjs"},"./package.json":"./package.json"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:96304087-c1f3-4da4-ac91-2caf5b73a57e"}},"repository":{"url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git","type":"git"},"_npmVersion":"11.6.2","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/http-params-processor-key-flat_11.1.0_1768758917358_0.8137284876985733","host":"s3://npm-registry-packages-npm-production"}},"12.0.0":{"name":"@adaskothebeast/http-params-processor-key-flat","version":"12.0.0","description":"Flat, separator joined key formatting strategy for HttpParamsProcessor, for legacy APIs without nested keys.","keywords":["http","http-params","query-string","query-params","querystring","nested-objects","serializer","typescript","key-formatting","flat","legacy-api"],"license":"MIT","author":{"name":"Adam Pluciński","email":"adaskothebeast@gmail.com","url":"https://github.com/adaskothebeast"},"repository":{"type":"git","url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git"},"bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","type":"module","sideEffects":false,"main":"./index.cjs","module":"./index.js","types":"./index.d.ts","peerDependencies":{"@adaskothebeast/http-params-processor-core":"^12.0.0"},"exports":{".":{"types":"./index.d.ts","import":"./index.js","default":"./index.js","require":"./index.cjs"},"./package.json":"./package.json"},"gitHead":"73d31a6c26a6f2819f6c98aabb36659532e4cdd0","_id":"@adaskothebeast/http-params-processor-key-flat@12.0.0","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-zyu7GkSF9wL2kSPdnxmDyWwfAW9DwZExPDmWU9GNG/BqHayMY4O3IAZhmLsfoRg5z3zd4NIm3C+4thM9jhLhOA==","shasum":"5f3a330ad286d7201529bbe23d7820a4311ea7cd","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-key-flat/-/http-params-processor-key-flat-12.0.0.tgz","fileCount":9,"unpackedSize":13361,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCcecCtRVHcUgspU4HxizNMoho0IAAT6WP+Helxlr76LQIhAP1ceM01JC8l6OBXjb0lh9TDmxMYSqcLA1YE+e7++uQq"}]},"_npmUser":{"name":"adasko","email":"adaskothebeast@gmail.com"},"directories":{},"maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/http-params-processor-key-flat_12.0.0_1785235962937_0.8610836341452606"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-10T20:32:21.720Z","modified":"2026-07-28T10:52:43.287Z","10.0.0":"2026-01-10T20:32:21.987Z","11.0.0":"2026-01-18T17:42:55.649Z","11.1.0":"2026-01-18T17:55:17.497Z","12.0.0":"2026-07-28T10:52:43.083Z"},"bugs":{"url":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor/issues"},"author":{"name":"Adam Pluciński","email":"adaskothebeast@gmail.com","url":"https://github.com/adaskothebeast"},"license":"MIT","homepage":"https://github.com/AdaskoTheBeAsT/HttpParamsProcessor","repository":{"type":"git","url":"git+https://github.com/AdaskoTheBeAsT/HttpParamsProcessor.git"},"maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"readme":"# ➖ @adaskothebeast/http-params-processor-key-flat\n\n**Flat, separator joined key formatting for [HttpParamsProcessor](https://github.com/AdaskoTheBeAsT/HttpParamsProcessor): `user_profile_email`, `items_0`, no brackets or dots anywhere.**\n\n[![npm](https://img.shields.io/npm/v/%40adaskothebeast%2Fhttp-params-processor-key-flat?color=cb3837&logo=npm)](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-key-flat)\n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n\nNo runtime dependency beyond `core` (its only peer dependency, `^12.0.0`). ESM + CJS. `sideEffects: false`.\n\n---\n\n## 📦 Install\n\n```bash\nnpm i @adaskothebeast/http-params-processor-key-flat @adaskothebeast/http-params-processor-core\n```\n\n---\n\n## 🎯 What it does\n\nThis is a **key formatting strategy**: it decides how nested keys are spelled while `ParamsProcessor` walks your object graph. It joins every level (object properties _and_ array indices) with a single separator, so the resulting query string contains only plain identifier-like names. That is what legacy APIs, CGI style endpoints, form field naming conventions and validators that reject `[`, `]` or `.` in parameter names need.\n\n| Input                        | `DefaultKeyFormattingStrategy` (core) | `FlatKeyFormattingStrategy` (default) |\n| ---------------------------- | ------------------------------------- | ------------------------------------- |\n| `{ user: { name: 'John' } }` | `p.user.name`                         | `p_user_name`                         |\n| `{ items: ['a', 'b'] }`      | `p.items[0]`, `p.items[1]`            | `p_items_0`, `p_items_1`              |\n| `{ arr: [{ id: '1' }] }`     | `p.arr[0].id`                         | `p_arr_0_id`                          |\n\nKeys need no percent encoding with the default `_` separator, which keeps URLs readable in logs.\n\n---\n\n## 🧰 API\n\n### `FlatKeyFormattingStrategy`\n\nImplements `IKeyFormattingStrategy` from `core`.\n\n| Member                                      | Returns  | Result                                         |\n| ------------------------------------------- | -------- | ---------------------------------------------- |\n| `new FlatKeyFormattingStrategy(separator?)` | -        | `separator` defaults to `'_'`                  |\n| `formatObjectKey(parentKey, propertyKey)`   | `string` | `` `${parentKey}${separator}${propertyKey}` `` |\n| `formatArrayKey(parentKey, index)`          | `string` | `` `${parentKey}${separator}${index}` ``       |\n\n`separator` is any string, not a restricted union: `'-'`, `'__'`, `'.'`, `'::'` all work. `transformComplexObject` is not implemented, so nested objects and arrays are always traversed down to primitives.\n\n---\n\n## ⚡ Usage\n\n```ts\nimport { ParamsProcessor } from '@adaskothebeast/http-params-processor-core';\nimport { FlatKeyFormattingStrategy } from '@adaskothebeast/http-params-processor-key-flat';\n\nconst processor = new ParamsProcessor({\n  keyFormatter: new FlatKeyFormattingStrategy(),\n});\n\nprocessor.process('p', {\n  user: { name: 'John', profile: { email: 'john@example.com' } },\n  items: ['a', 'b'],\n});\n// [\n//   ['p_user_name', 'John'],\n//   ['p_user_profile_email', 'john@example.com'],\n//   ['p_items_0', 'a'],\n//   ['p_items_1', 'b'],\n// ]\n```\n\nThe same `keyFormatter` option is accepted by every adapter (`-angular`, `-angular-resource`, `-fetch`, `-axios`, `-react-tanstack-query`, `-react-swr`), because they all forward their options object to `ParamsProcessor`.\n\n---\n\n## 🎛️ Options and configuration\n\n```ts\nnew FlatKeyFormattingStrategy(); // '_'  -> user_name, items_0\nnew FlatKeyFormattingStrategy('-'); // '-'  -> user-name, items-0\nnew FlatKeyFormattingStrategy('__'); // '__' -> user__name, items__0\n```\n\n| Separator | `user` + `name` | `items` + `0` | Notes                                             |\n| --------- | --------------- | ------------- | ------------------------------------------------- |\n| `'_'`     | `user_name`     | `items_0`     | Default, URL safe, no encoding                    |\n| `'-'`     | `user-name`     | `items-0`     | URL safe, common for kebab-case backends          |\n| `'__'`    | `user__name`    | `items__0`    | Reduces collisions with `_` inside property names |\n| `'.'`     | `user.name`     | `items.0`     | Dots everywhere, including array indices          |\n\nThe same separator is used for objects and arrays by design; there is no separate array format. If you want dots (or another delimiter) for objects but keep `items[0]` for arrays, use [`-key-custom-delimiter`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-key-custom-delimiter).\n\nThe strategy is stateless, so a single instance can be shared, and `keyFormatter` can also be passed per call to override the processor default.\n\n---\n\n## 📤 Output examples\n\n```ts\nconst processor = new ParamsProcessor({\n  keyFormatter: new FlatKeyFormattingStrategy(),\n});\n\nprocessor.process('p', { arr: [{ id: '1', innerArr: [{ id: '1.1' }] }] });\n```\n\n```text\np_arr_0_id                = 1\np_arr_0_innerArr_0_id     = 1.1\n```\n\n```ts\nprocessor.toQueryString('p', { user: { name: 'John' }, items: ['a'] });\n// p_user_name=John&p_items_0=a\n\nprocessor.toPlainObject('p', { user: { tags: ['a', 'b'] } });\n// { 'p_user_tags_0': 'a', 'p_user_tags_1': 'b' }\n```\n\nBackends that expect `user_name` / `items_0` style parameters (hand written PHP/Perl/CGI handlers, ASP.NET Web Forms style names, form encoded gateways, analytics collectors) bind these directly without a nested query parser.\n\n---\n\n## ⚠️ Edge cases\n\n- **Flattening is lossy.** `{ user_name: 'x' }` and `{ user: { name: 'x' } }` both produce `p_user_name`, and if two branches collide the later pair simply repeats the key. Pick a separator that cannot appear in your property names (`'__'` is a good compromise) or rename the properties.\n- Array indices are joined the same way as properties, so `p_items_0` is indistinguishable from an object property literally named `0`. Most backends cannot rebuild arrays from this shape - they read `p_items_0`, `p_items_1` as separate fields.\n- An **empty root key** produces a leading separator (`process('', { user: 1 })` gives `_user`). Pass a real root name.\n- Separators are not escaped or validated: a separator such as `'&'` or `'='` would produce broken looking keys once encoded (`toQueryString` percent encodes them, so the query string stays parseable but the key is ugly).\n- Deeply nested graphs create long names; watch server limits on parameter name length and on total query string size.\n- `null`/`undefined` values, `$type` discriminators, empty objects and empty arrays are dropped by `core` before this strategy is consulted; circular references throw `Error: Circular reference detected at key: <key>`.\n\n---\n\n## 🔗 Related packages\n\n- Nested-capable alternatives: [`-key-bracket-notation`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-key-bracket-notation) (`user[name]`), [`-key-rails`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-key-rails) (`items[]`)\n- Mixed shape: [`-key-custom-delimiter`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-key-custom-delimiter) (custom object delimiter, brackets or delimiter for arrays)\n- Single parameter: [`-key-json`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-key-json)\n- Engine: [`-core`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-core)\n\nFull matrix and adapter recipes: [main README](https://github.com/AdaskoTheBeAsT/HttpParamsProcessor#readme).\n\n---\n\n## 📄 License\n\n[MIT](./LICENSE) © Adam Pluciński\n","readmeFilename":"README.md","description":"Flat, separator joined key formatting strategy for HttpParamsProcessor, for legacy APIs without nested keys.","keywords":["http","http-params","query-string","query-params","querystring","nested-objects","serializer","typescript","key-formatting","flat","legacy-api"]}