{"_id":"@adaskothebeast/http-params-processor-value-from-dayjs","_rev":"4-2959a45d45626bd4f8685193e90c0e86","name":"@adaskothebeast/http-params-processor-value-from-dayjs","dist-tags":{"latest":"12.0.0"},"versions":{"10.0.0":{"name":"@adaskothebeast/http-params-processor-value-from-dayjs","version":"10.0.0","_id":"@adaskothebeast/http-params-processor-value-from-dayjs@10.0.0","maintainers":[{"name":"adasko","email":"adaskothebeast@gmail.com"}],"dist":{"shasum":"930182891b93ad8817ef05e2acd1e0771b6de5e8","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-from-dayjs/-/http-params-processor-value-from-dayjs-10.0.0.tgz","fileCount":19,"integrity":"sha512-yKpO3Zciroc4HH6p8cJoJiBzQItj3SLD4jJWaFrsOWaOmXE2EdCsGNTA3/7Lb6jk3w+fCZgoH7HFGqQ+uQm1vQ==","signatures":[{"sig":"MEUCIQDQVl630ZTSZZAeDfrlIkVJDCVnYBE86YWl2fAUkJ9h1AIgDPiWIvxgEbf0lBBMeyzYMGCOEQCPAFqzEmpQb2/wE1A=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":31118},"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":{"dayjs":"*","@adaskothebeast/http-params-processor-core":"^10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/http-params-processor-value-from-dayjs_10.0.0_1768077205860_0.9952729724219822","host":"s3://npm-registry-packages-npm-production"}},"11.0.0":{"name":"@adaskothebeast/http-params-processor-value-from-dayjs","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-value-from-dayjs@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":"c9df9f29ac2c92bd12f54b168b075656e7ab5bf9","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-from-dayjs/-/http-params-processor-value-from-dayjs-11.0.0.tgz","fileCount":10,"integrity":"sha512-p/HN1DAYK3wTdbyDX1+50A48AnTTMmMzr3UnQCq/dYe63wKZMQYBESFPLwzssn0xm4atsQcfuC2MXQNu6fmSSw==","signatures":[{"sig":"MEQCIAjsbxOq9qKMd+gDyyUJXDUKwVWTag3KHrvPNKeacIp7AiA+IGckGfAmgpMsQGr1InrPvdAu5/eHaYLqeSHcxsh4IQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaskothebeast%2fhttp-params-processor-value-from-dayjs@11.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":43155},"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:d7e652fe-52a6-4a0a-9f65-784eb9adeee3"}},"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-value-from-dayjs_11.0.0_1768758181245_0.30780992895756687","host":"s3://npm-registry-packages-npm-production"}},"11.1.0":{"name":"@adaskothebeast/http-params-processor-value-from-dayjs","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-value-from-dayjs@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":"ac00e1003e5821d05ebb0138e18b2cbf40308966","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-from-dayjs/-/http-params-processor-value-from-dayjs-11.1.0.tgz","fileCount":10,"integrity":"sha512-Bokdb02nTt7E7c2V2Hn8M0Jx+n7MlQaLQTfSI7uCffojb65BHpDwBnIJz0qXbnGHgjUnbOMDrGtP0q7EhW7ASA==","signatures":[{"sig":"MEYCIQCkoZcRKPdnhUMFX/qp/Zz9ALuyNf+Qm650YG7xRlufQQIhAIscioM0zdFnQ7M2taYy3HG7JG86yfjojvI2ogW6mK/4","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@adaskothebeast%2fhttp-params-processor-value-from-dayjs@11.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":43155},"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:d7e652fe-52a6-4a0a-9f65-784eb9adeee3"}},"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-value-from-dayjs_11.1.0_1768758917715_0.7579621300120005","host":"s3://npm-registry-packages-npm-production"}},"12.0.0":{"name":"@adaskothebeast/http-params-processor-value-from-dayjs","version":"12.0.0","description":"Day.js date and duration input strategies for HttpParamsProcessor value conversion.","keywords":["http","http-params","query-string","query-params","querystring","nested-objects","serializer","typescript","value-conversion","dayjs","date","duration"],"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","dayjs":"^1.11.21"},"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-value-from-dayjs@12.0.0","_nodeVersion":"24.18.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-rKm1qljiQHqErRtuAnAFS439iA3Ab83PBjGIOWrLms3Befdwuj6zJC1EqhRvaXQa6C+dT3Gfu8Crdt2ERza8Ew==","shasum":"a6a8b878b2a7f9b66f81575436af2109179b299f","tarball":"https://registry.npmjs.org/@adaskothebeast/http-params-processor-value-from-dayjs/-/http-params-processor-value-from-dayjs-12.0.0.tgz","fileCount":11,"unpackedSize":17179,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIFPGjmvascKjzcTimkcw9avP+gsRK7e7ykLyZsgj5TF1AiAHAIYzBk9SI3vZryj0boPDnbhc8uwxL3KFwV+ap4aslQ=="}]},"_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-value-from-dayjs_12.0.0_1785236157613_0.4659057591391502"},"_hasShrinkwrap":false}},"time":{"created":"2026-01-10T20:33:25.752Z","modified":"2026-07-28T10:55:57.954Z","10.0.0":"2026-01-10T20:33:26.012Z","11.0.0":"2026-01-18T17:43:01.378Z","11.1.0":"2026-01-18T17:55:17.882Z","12.0.0":"2026-07-28T10:55:57.752Z"},"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-value-from-dayjs\n\n**Day.js input strategies for [HttpParamsProcessor](https://github.com/AdaskoTheBeAsT/HttpParamsProcessor): normalize `Dayjs` instants and Day.js `Duration` objects before they are serialized.**\n\n[![npm](https://img.shields.io/npm/v/%40adaskothebeast%2Fhttp-params-processor-value-from-dayjs?color=cb3837&logo=npm)](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-from-dayjs)\n[![license](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n\nPeer dependencies: `core` and `dayjs` (`^1.11.21`). ESM + CJS. `sideEffects: false`.\n\n---\n\n## 📦 Install\n\n```bash\nnpm i @adaskothebeast/http-params-processor-value-from-dayjs @adaskothebeast/http-params-processor-core dayjs\n```\n\nNo extra plugin package is needed: the duration strategy pulls `dayjs/plugin/duration` in itself.\n\n---\n\n## 🎯 What it does\n\nThese are **value-from** strategies: the first half of the conversion pipeline. Each one normalizes a Day.js type into a neutral shape and must be paired with a **value-to** strategy (`-value-to-iso`, `-value-to-nodatime`, `-value-to-unix-timestamp`, `-value-to-ms-timestamp`, `-value-to-date-fns`) through `createValueConverter`.\n\n| Class                            | Accepts                                     | Produces                                                                                        |\n| -------------------------------- | ------------------------------------------- | ----------------------------------------------------------------------------------------------- |\n| `DayjsDateValueFromStrategy`     | `Dayjs` (detected by `dayjs.isDayjs`)       | `Date` (`value.toDate()`)                                                                       |\n| `DayjsDurationValueFromStrategy` | `Duration` (detected by `dayjs.isDuration`) | `DurationComponents` (`years`, `months`, `days`, `hours`, `minutes`, `seconds`, `milliseconds`) |\n\nDetection is exact and mutually exclusive: a `Dayjs` object is never claimed by the duration strategy and vice versa, so both converters can be registered side by side.\n\n---\n\n## ⚡ Usage\n\n```ts\nimport { DefaultDateValueFromStrategy, ParamsProcessor, createValueConverter } from '@adaskothebeast/http-params-processor-core';\nimport { DayjsDateValueFromStrategy, DayjsDurationValueFromStrategy } from '@adaskothebeast/http-params-processor-value-from-dayjs';\nimport { IsoDateValueToStrategy, IsoDurationValueToStrategy } from '@adaskothebeast/http-params-processor-value-to-iso';\nimport dayjs from 'dayjs';\nimport duration from 'dayjs/plugin/duration';\n\ndayjs.extend(duration);\n\nconst processor = new ParamsProcessor({\n  valueConverters: [\n    createValueConverter(new DayjsDateValueFromStrategy(), new IsoDateValueToStrategy()),\n    createValueConverter(new DayjsDurationValueFromStrategy(), new IsoDurationValueToStrategy()),\n    // keep native Dates working too\n    createValueConverter(new DefaultDateValueFromStrategy(), new IsoDateValueToStrategy()),\n  ],\n});\n\nprocessor.process('p', {\n  from: dayjs('2024-01-15T10:30:00.000Z'),\n  window: dayjs.duration({ hours: 1, minutes: 30, seconds: 45 }),\n});\n// [['p.from', '2024-01-15T10:30:00.000Z'], ['p.window', 'PT1H30M45S']]\n```\n\n---\n\n## 🎛️ Options and configuration\n\nNeither strategy takes constructor options - both are stateless and safe to share between processors.\n\n**The duration plugin.** `DayjsDurationValueFromStrategy` imports `dayjs/plugin/duration` and calls `dayjs.extend(durationPlugin)` at module load, so the plugin is always registered before the strategy runs. Your own code still needs its own `dayjs.extend(duration)` call to create durations: it gives you the `dayjs.duration` typings and makes the call independent of import order.\n\n**Output format** is decided entirely by the paired value-to strategy. `Dayjs` normalizes to a `Date` (an instant), so any date writer works:\n\n```ts\nimport { UnixTimestampValueToStrategy } from '@adaskothebeast/http-params-processor-value-to-unix-timestamp';\n\ncreateValueConverter(new DayjsDateValueFromStrategy(), new UnixTimestampValueToStrategy());\n```\n\n**Registration order** matters only against strategies with overlapping detection. Put these before `DefaultDateValueFromStrategy` if you also register it - `Dayjs` is not a `Date`, so in practice they never compete.\n\n---\n\n## 📤 Output examples\n\nPaired with `-value-to-iso`:\n\n| Value passed to `process`                   | Normalized shape            | Serialized                 |\n| ------------------------------------------- | --------------------------- | -------------------------- |\n| `dayjs('2024-01-15T10:30:00.000Z')`         | `Date` (instant)            | `2024-01-15T10:30:00.000Z` |\n| `dayjs.duration({ hours: 1, minutes: 30 })` | `{ hours: 1, minutes: 30 }` | `PT1H30M`                  |\n| `dayjs.duration({ minutes: 90 })`           | `{ minutes: 90 }`           | `PT90M`                    |\n| `dayjs.duration(5400000)`                   | `{ hours: 1, minutes: 30 }` | `PT1H30M`                  |\n| `dayjs.duration('PT1H30M')`                 | `{ hours: 1, minutes: 30 }` | `PT1H30M`                  |\n| `dayjs.duration({ months: 18 })`            | `{ months: 18 }`            | `P18M`                     |\n| `dayjs.duration({ days: 5, hours: 2 })`     | `{ days: 5, hours: 2 }`     | `P5DT2H`                   |\n| `dayjs.duration({ weeks: 2 })`              | `{}`                        | `PT0S`                     |\n\n```text\np.from    = 2024-01-15T10:30:00.000Z\np.window  = PT1H30M45S\n```\n\n---\n\n## ⚠️ Edge cases\n\n- **Weeks are dropped.** Day.js keeps `weeks` in its own slot and reports `days()` as `0` for `dayjs.duration({ weeks: 2 })`, and the strategy maps only `years`, `months`, `days` and the time fields. Such a duration normalizes to an empty object (`PT0S` with the ISO writer) - pass `{ days: 14 }` instead.\n- **Object-built durations are not normalized.** `dayjs.duration({ minutes: 90 })` stays `PT90M`; only millisecond and ISO-string inputs are split into hours/minutes/seconds by Day.js itself. Use `dayjs.duration(dur.asMilliseconds())` if you need the carried form.\n- Zero components are converted to `undefined`, so `{ hours: 1 }` never emits `0` days or minutes, and `dayjs.duration(0)` normalizes to an empty object.\n- **Invalid dates still pass `canHandle`.** `dayjs('not-a-date')` is a `Dayjs` object, so it is claimed and normalized to `Invalid Date`; `IsoDateValueToStrategy` then throws `RangeError: Invalid time value` (timestamp writers emit `NaN`). Filter with `.isValid()` before building your params object.\n- Time zone and UTC metadata (from `dayjs/plugin/timezone` or `dayjs/plugin/utc`) is **not** carried over: `toDate()` yields a plain instant, and the paired writer decides the rendering (the ISO writer always emits UTC with `Z`).\n- `dayjs.duration()` results are not instants; never pair `DayjsDurationValueFromStrategy` with a date writer such as `IsoDateValueToStrategy` - the converter always runs the paired writer, it does not re-check the shape.\n- **Avoid fractional seconds.** Day.js reports them twice: `dayjs.duration({ seconds: 1.5 })` yields `{ seconds: 1.5, milliseconds: 500 }`, and the ISO writer adds the fraction to the milliseconds, producing `PT2S`. Pass `{ seconds: 1, milliseconds: 500 }` instead.\n\n---\n\n## 🔗 Related packages\n\n- Outputs: [`-value-to-iso`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-iso), [`-value-to-nodatime`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-nodatime), [`-value-to-unix-timestamp`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-unix-timestamp), [`-value-to-ms-timestamp`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-ms-timestamp), [`-value-to-date-fns`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-to-date-fns)\n- Other inputs: [`-value-from-luxon`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-from-luxon), [`-value-from-moment`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-from-moment), [`-value-from-js-joda`](https://www.npmjs.com/package/@adaskothebeast/http-params-processor-value-from-js-joda)\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":"Day.js date and duration input strategies for HttpParamsProcessor value conversion.","keywords":["http","http-params","query-string","query-params","querystring","nested-objects","serializer","typescript","value-conversion","dayjs","date","duration"]}