@openclaw/whatsapp 2026.7.1-beta.2 → 2026.7.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{access-control-88UPniDc.js → access-control-DYE5dXna.js} +5 -3
- package/dist/{accounts-DgViSyJx.js → accounts-4YgwroRU.js} +1 -1
- package/dist/{action-runtime-hqza0J8B.js → action-runtime-DPahAqxV.js} +2 -2
- package/dist/action-runtime-api.js +1 -1
- package/dist/action-runtime.runtime.js +1 -1
- package/dist/{active-listener-CFwkn3ho.js → active-listener-B4SDebQ6.js} +1 -1
- package/dist/api.js +14 -13
- package/dist/{approval-handler.runtime-9_SV7vhc.js → approval-handler.runtime-DNWS4aYQ.js} +1 -1
- package/dist/auth-presence.js +1 -1
- package/dist/{auth-store-ECx4h57q.js → auth-store-Db-wfApd.js} +23 -13
- package/dist/call-tool-api.js +233 -0
- package/dist/{channel-fcXxWXic.js → channel-BWp7h1uY.js} +44 -18
- package/dist/channel-config-api.js +1 -1
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel-react-action-Dgy9uUMl.js → channel-react-action-CKJHL_Wf.js} +3 -3
- package/dist/{channel.runtime-B4ThooGF.js → channel.runtime-CAssfx9p.js} +5 -5
- package/dist/{channel.setup-C_WEdyJR.js → channel.setup-CURc5rEt.js} +2 -2
- package/dist/{config-schema-CROZuhT-.js → config-schema-mBX2nmn1.js} +4 -0
- package/dist/{connection-controller-u-tfAFhJ.js → connection-controller-DkbrFSIn.js} +6 -5
- package/dist/connection-controller-registry-TSX_udJp.js +22 -0
- package/dist/contract-api.js +1 -1
- package/dist/{quoted-message-CpA_ujXK.js → group-session-key-BhC1RQOE.js} +31 -2
- package/dist/{identity-CmsTmkKR.js → identity-Dqft3mFA.js} +2 -1
- package/dist/index.js +9 -2
- package/dist/light-runtime-api.js +3 -3
- package/dist/{login-8lHwLmXj.js → login-C48y0jlx.js} +14 -7
- package/dist/{login-qr-BEZZqrTb.js → login-qr-BjId7dll.js} +7 -7
- package/dist/login-qr-runtime.js +1 -1
- package/dist/{monitor-BqkJ4MpT.js → monitor-DD8bXohk.js} +249 -160
- package/dist/runtime-api.js +9 -9
- package/dist/{send-i8Xk5mBQ.js → send-C5CpFcBG.js} +27 -9
- package/dist/{send-api-DndiBJhN.js → send-api-DLlXl8CH.js} +6 -5
- package/dist/{session-WU4SVP8f.js → session-DriaHt7V.js} +3 -3
- package/dist/{session-errors-CbsoQqoy.js → session-errors-BAj9D2La.js} +1 -22
- package/dist/{setup-core-KjSBbWX4.js → setup-core-DH-DFPLY.js} +4 -4
- package/dist/{setup-finalize-WedNP30s.js → setup-finalize-c8dl34sO.js} +3 -3
- package/dist/setup-plugin-api.js +1 -1
- package/dist/{setup-surface-IOdkbWsQ.js → setup-surface-DlWb0Z09.js} +3 -3
- package/dist/{socket-timing-DvMNkIge.js → socket-timing-DhbVFjah.js} +17 -5
- package/dist/{text-runtime-C88QkuU9.js → targets-runtime-C-GiVn6Y.js} +2 -3
- package/dist/text-runtime-DdX6-mC_.js +4 -0
- package/node_modules/@cacheable/memory/README.md +177 -0
- package/node_modules/@cacheable/memory/dist/index.cjs +867 -820
- package/node_modules/@cacheable/memory/dist/index.d.cts +382 -280
- package/node_modules/@cacheable/memory/dist/index.d.mts +412 -0
- package/node_modules/@cacheable/memory/dist/index.mjs +841 -0
- package/node_modules/@cacheable/memory/package.json +9 -9
- package/node_modules/@cacheable/utils/README.md +342 -8
- package/node_modules/@cacheable/utils/dist/index.cjs +1322 -619
- package/node_modules/@cacheable/utils/dist/index.d.cts +769 -173
- package/node_modules/@cacheable/utils/dist/index.d.mts +903 -0
- package/node_modules/@cacheable/utils/dist/index.mjs +1355 -0
- package/node_modules/@cacheable/utils/package.json +8 -8
- package/node_modules/@types/node/README.md +1 -1
- package/node_modules/@types/node/assert/strict.d.ts +10 -1
- package/node_modules/@types/node/assert.d.ts +144 -17
- package/node_modules/@types/node/async_hooks.d.ts +9 -9
- package/node_modules/@types/node/buffer.d.ts +64 -30
- package/node_modules/@types/node/child_process.d.ts +17 -21
- package/node_modules/@types/node/cluster.d.ts +13 -13
- package/node_modules/@types/node/console.d.ts +1 -1
- package/node_modules/@types/node/crypto.d.ts +471 -575
- package/node_modules/@types/node/diagnostics_channel.d.ts +274 -32
- package/node_modules/@types/node/dns.d.ts +15 -15
- package/node_modules/@types/node/events.d.ts +3 -3
- package/node_modules/@types/node/ffi.d.ts +486 -0
- package/node_modules/@types/node/fs/promises.d.ts +7 -4
- package/node_modules/@types/node/fs.d.ts +24 -18
- package/node_modules/@types/node/globals.d.ts +4 -4
- package/node_modules/@types/node/http.d.ts +30 -5
- package/node_modules/@types/node/http2.d.ts +5 -1
- package/node_modules/@types/node/index.d.ts +1 -3
- package/node_modules/@types/node/inspector.d.ts +1 -1
- package/node_modules/@types/node/module.d.ts +16 -45
- package/node_modules/@types/node/net.d.ts +1 -1
- package/node_modules/@types/node/os.d.ts +2 -2
- package/node_modules/@types/node/package.json +4 -4
- package/node_modules/@types/node/perf_hooks.d.ts +1 -9
- package/node_modules/@types/node/process.d.ts +25 -12
- package/node_modules/@types/node/quic.d.ts +92 -11
- package/node_modules/@types/node/readline.d.ts +12 -11
- package/node_modules/@types/node/repl.d.ts +10 -10
- package/node_modules/@types/node/sqlite.d.ts +56 -1
- package/node_modules/@types/node/stream/iter.d.ts +150 -0
- package/node_modules/@types/node/stream/promises.d.ts +2 -2
- package/node_modules/@types/node/stream/web.d.ts +1 -1
- package/node_modules/@types/node/stream.d.ts +37 -5
- package/node_modules/@types/node/test/reporters.d.ts +1 -1
- package/node_modules/@types/node/test.d.ts +120 -10
- package/node_modules/@types/node/tls.d.ts +1 -1
- package/node_modules/@types/node/ts5.6/index.d.ts +2 -4
- package/node_modules/@types/node/ts5.7/index.d.ts +1 -3
- package/node_modules/@types/node/url.d.ts +3 -3
- package/node_modules/@types/node/util/types.d.ts +1 -1
- package/node_modules/@types/node/util.d.ts +22 -22
- package/node_modules/@types/node/v8.d.ts +85 -3
- package/node_modules/@types/node/vm.d.ts +9 -9
- package/node_modules/@types/node/web-globals/domexception.d.ts +15 -0
- package/node_modules/@types/node/worker_threads.d.ts +10 -12
- package/node_modules/@types/node/zlib.d.ts +3 -3
- package/node_modules/cacheable/README.md +309 -30
- package/node_modules/cacheable/dist/index.cjs +1307 -1153
- package/node_modules/cacheable/dist/index.d.cts +741 -469
- package/node_modules/cacheable/dist/index.d.mts +766 -0
- package/node_modules/cacheable/dist/index.mjs +1210 -0
- package/node_modules/cacheable/package.json +10 -10
- package/node_modules/content-type/README.md +32 -57
- package/node_modules/content-type/dist/index.d.ts +26 -0
- package/node_modules/content-type/dist/index.js +170 -0
- package/node_modules/content-type/dist/index.js.map +1 -0
- package/node_modules/content-type/package.json +35 -25
- package/node_modules/media-typer/README.md +19 -33
- package/node_modules/media-typer/dist/index.d.ts +29 -0
- package/node_modules/media-typer/dist/index.js +64 -0
- package/node_modules/media-typer/dist/index.js.map +1 -0
- package/node_modules/media-typer/package.json +37 -22
- package/node_modules/music-metadata/lib/id3v1/ID3v1Parser.js +2 -2
- package/node_modules/music-metadata/lib/mp4/AtomToken.js +65 -13
- package/node_modules/music-metadata/lib/wav/WaveChunk.d.ts +10 -0
- package/node_modules/music-metadata/lib/wav/WaveChunk.js +13 -3
- package/node_modules/music-metadata/lib/wav/WaveParser.d.ts +1 -0
- package/node_modules/music-metadata/lib/wav/WaveParser.js +6 -5
- package/node_modules/music-metadata/package.json +5 -5
- package/node_modules/typebox/build/compile/validator.d.mts +2 -7
- package/node_modules/typebox/build/compile/validator.mjs +6 -36
- package/node_modules/typebox/build/error/errors.d.mts +1 -7
- package/node_modules/typebox/build/format/_idna.mjs +36 -6
- package/node_modules/typebox/build/format/_puny.mjs +4 -1
- package/node_modules/typebox/build/format/uuid.d.mts +2 -2
- package/node_modules/typebox/build/format/uuid.mjs +3 -3
- package/node_modules/typebox/build/guard/emit.d.mts +0 -4
- package/node_modules/typebox/build/guard/emit.mjs +0 -8
- package/node_modules/typebox/build/guard/guard.d.mts +4 -8
- package/node_modules/typebox/build/guard/guard.mjs +5 -13
- package/node_modules/typebox/build/schema/engine/boolean.d.mts +3 -3
- package/node_modules/typebox/build/schema/engine/boolean.mjs +4 -4
- package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
- package/node_modules/typebox/build/schema/engine/schema.mjs +5 -10
- package/node_modules/typebox/build/schema/engine/type.mjs +14 -18
- package/node_modules/typebox/build/schema/types/dependencies.mjs +1 -1
- package/node_modules/typebox/build/schema/types/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/types/index.mjs +0 -1
- package/node_modules/typebox/build/schema/types/schema.d.mts +1 -1
- package/node_modules/typebox/build/schema/types/schema.mjs +2 -2
- package/node_modules/typebox/build/system/locale/ar_001.mjs +0 -1
- package/node_modules/typebox/build/system/locale/bn_BD.mjs +0 -1
- package/node_modules/typebox/build/system/locale/cs_CZ.mjs +0 -1
- package/node_modules/typebox/build/system/locale/de_DE.mjs +0 -1
- package/node_modules/typebox/build/system/locale/el_GR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/en_US.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_419.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_AR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_ES.mjs +0 -1
- package/node_modules/typebox/build/system/locale/es_MX.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fa_IR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fil_PH.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fr_CA.mjs +0 -1
- package/node_modules/typebox/build/system/locale/fr_FR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ha_NG.mjs +0 -1
- package/node_modules/typebox/build/system/locale/hi_IN.mjs +0 -1
- package/node_modules/typebox/build/system/locale/hu_HU.mjs +0 -1
- package/node_modules/typebox/build/system/locale/id_ID.mjs +0 -1
- package/node_modules/typebox/build/system/locale/it_IT.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ja_JP.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ko_KR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ms_MY.mjs +0 -1
- package/node_modules/typebox/build/system/locale/nl_NL.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pl_PL.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pt_BR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/pt_PT.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ro_RO.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ru_RU.mjs +0 -1
- package/node_modules/typebox/build/system/locale/sv_SE.mjs +0 -1
- package/node_modules/typebox/build/system/locale/sw_TZ.mjs +0 -1
- package/node_modules/typebox/build/system/locale/th_TH.mjs +0 -1
- package/node_modules/typebox/build/system/locale/tr_TR.mjs +0 -1
- package/node_modules/typebox/build/system/locale/uk_UA.mjs +0 -1
- package/node_modules/typebox/build/system/locale/ur_PK.mjs +0 -1
- package/node_modules/typebox/build/system/locale/vi_VN.mjs +0 -1
- package/node_modules/typebox/build/system/locale/yo_NG.mjs +0 -1
- package/node_modules/typebox/build/system/locale/zh_Hans.mjs +0 -1
- package/node_modules/typebox/build/system/locale/zh_Hant.mjs +0 -1
- package/node_modules/typebox/build/system/memory/clone.d.mts +2 -3
- package/node_modules/typebox/build/system/memory/clone.mjs +73 -26
- package/node_modules/typebox/build/system/settings/settings.d.mts +15 -0
- package/node_modules/typebox/build/system/settings/settings.mjs +3 -1
- package/node_modules/typebox/build/type/action/_add_immutable.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_immutable.mjs +11 -0
- package/node_modules/typebox/build/type/action/_add_optional.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_optional.mjs +11 -0
- package/node_modules/typebox/build/type/action/_add_readonly.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_add_readonly.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_immutable.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_immutable.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_optional.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_optional.mjs +11 -0
- package/node_modules/typebox/build/type/action/_remove_readonly.d.mts +11 -0
- package/node_modules/typebox/build/type/action/_remove_readonly.mjs +11 -0
- package/node_modules/typebox/build/type/action/conditional.d.mts +2 -3
- package/node_modules/typebox/build/type/action/conditional.mjs +2 -1
- package/node_modules/typebox/build/type/action/index.d.mts +7 -4
- package/node_modules/typebox/build/type/action/index.mjs +7 -4
- package/node_modules/typebox/build/type/action/mapped.d.mts +2 -3
- package/node_modules/typebox/build/type/action/mapped.mjs +2 -1
- package/node_modules/typebox/build/type/action/module.d.mts +8 -7
- package/node_modules/typebox/build/type/action/module.mjs +7 -6
- package/node_modules/typebox/build/type/action/readonly_object.d.mts +0 -5
- package/node_modules/typebox/build/type/action/readonly_object.mjs +0 -5
- package/node_modules/typebox/build/type/action/with.d.mts +11 -0
- package/node_modules/typebox/build/type/action/with.mjs +11 -0
- package/node_modules/typebox/build/type/engine/call/distribute_arguments.mjs +1 -1
- package/node_modules/typebox/build/type/engine/call/instantiate.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/call/instantiate.mjs +3 -2
- package/node_modules/typebox/build/type/engine/call/resolve_arguments.mjs +2 -2
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.d.mts +3 -4
- package/node_modules/typebox/build/type/engine/constructor_parameters/instantiate.mjs +2 -1
- package/node_modules/typebox/build/type/engine/cyclic/candidates.d.mts +2 -3
- package/node_modules/typebox/build/type/engine/cyclic/candidates.mjs +3 -6
- package/node_modules/typebox/build/type/engine/cyclic/check.d.mts +6 -9
- package/node_modules/typebox/build/type/engine/cyclic/check.mjs +10 -16
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/cyclic/dependencies.mjs +9 -15
- package/node_modules/typebox/build/type/engine/cyclic/extends.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/cyclic/extends.mjs +8 -14
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.d.mts +2 -5
- package/node_modules/typebox/build/type/engine/cyclic/instantiate.mjs +3 -2
- package/node_modules/typebox/build/type/engine/enum/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/enum/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/broaden.d.mts +1 -2
- package/node_modules/typebox/build/type/engine/evaluate/broaden.mjs +2 -6
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +10 -6
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +10 -6
- package/node_modules/typebox/build/type/engine/evaluate/distribute.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/evaluate/distribute.mjs +3 -3
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.d.mts +17 -5
- package/node_modules/typebox/build/type/engine/evaluate/evaluate.mjs +34 -8
- package/node_modules/typebox/build/type/engine/exclude/operation.d.mts +5 -6
- package/node_modules/typebox/build/type/engine/exclude/operation.mjs +11 -12
- package/node_modules/typebox/build/type/engine/extract/operation.d.mts +5 -6
- package/node_modules/typebox/build/type/engine/extract/operation.mjs +11 -12
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/index.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/index.mjs +2 -2
- package/node_modules/typebox/build/type/engine/indexable/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/indexable/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/indexable/from_enum.d.mts +3 -3
- package/node_modules/typebox/build/type/engine/indexable/from_enum.mjs +4 -4
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/indexable/from_template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/engine/indexable/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/indexable/from_type.mjs +9 -6
- package/node_modules/typebox/build/type/engine/indexed/instantiate.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/indexed/instantiate.mjs +5 -2
- package/node_modules/typebox/build/type/engine/instantiate.d.mts +44 -31
- package/node_modules/typebox/build/type/engine/instantiate.mjs +82 -83
- package/node_modules/typebox/build/type/engine/interface/instantiate.d.mts +3 -6
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/intrinsics/from_template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/engine/keyof/instantiate.d.mts +2 -1
- package/node_modules/typebox/build/type/engine/keyof/instantiate.mjs +5 -1
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.d.mts +4 -4
- package/node_modules/typebox/build/type/engine/mapped/mapped_operation.mjs +3 -3
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.d.mts +5 -4
- package/node_modules/typebox/build/type/engine/mapped/mapped_variants.mjs +10 -5
- package/node_modules/typebox/build/type/engine/module/instantiate.d.mts +7 -9
- package/node_modules/typebox/build/type/engine/module/instantiate.mjs +17 -15
- package/node_modules/typebox/build/type/engine/object/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/object/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/object/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/object/from_type.mjs +8 -5
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/optional/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/parameters/instantiate.d.mts +3 -4
- package/node_modules/typebox/build/type/engine/parameters/instantiate.mjs +2 -1
- package/node_modules/typebox/build/type/engine/partial/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/partial/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/partial/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/partial/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/partial/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/partial/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/partial/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/partial/from_type.mjs +7 -4
- package/node_modules/typebox/build/type/engine/priority/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/priority/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/priority/priority.d.mts +20 -0
- package/node_modules/typebox/build/type/engine/priority/priority.mjs +28 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +14 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.d.mts +10 -0
- package/node_modules/typebox/build/type/engine/readonly/instantiate_remove.mjs +14 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_array.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_array.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/readonly_object/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_tuple.mjs +2 -2
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/readonly_object/from_type.mjs +8 -5
- package/node_modules/typebox/build/type/engine/record/from_key_enum.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_enum.mjs +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/record/from_key_template_literal.mjs +2 -2
- package/node_modules/typebox/build/type/engine/ref/instantiate.d.mts +3 -3
- package/node_modules/typebox/build/type/engine/ref/instantiate.mjs +6 -6
- package/node_modules/typebox/build/type/engine/required/from_dependent.d.mts +5 -0
- package/node_modules/typebox/build/type/engine/required/from_dependent.mjs +8 -0
- package/node_modules/typebox/build/type/engine/required/from_intersect.d.mts +1 -1
- package/node_modules/typebox/build/type/engine/required/from_intersect.mjs +3 -2
- package/node_modules/typebox/build/type/engine/required/from_object.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/required/from_object.mjs +2 -2
- package/node_modules/typebox/build/type/engine/required/from_type.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/required/from_type.mjs +7 -4
- package/node_modules/typebox/build/type/engine/template_literal/decode.mjs +3 -3
- package/node_modules/typebox/build/type/engine/template_literal/encode.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/template_literal/encode.mjs +6 -6
- package/node_modules/typebox/build/type/engine/template_literal/is_finite.mjs +1 -1
- package/node_modules/typebox/build/type/engine/template_literal/is_pattern.mjs +1 -0
- package/node_modules/typebox/build/type/engine/this/expand_this.d.mts +1 -4
- package/node_modules/typebox/build/type/engine/this/expand_this.mjs +7 -13
- package/node_modules/typebox/build/type/engine/with/instantiate.d.mts +8 -0
- package/node_modules/typebox/build/type/engine/{options → with}/instantiate.mjs +5 -5
- package/node_modules/typebox/build/type/extends/dependent.d.mts +6 -0
- package/node_modules/typebox/build/type/extends/dependent.mjs +6 -0
- package/node_modules/typebox/build/type/extends/enum.d.mts +4 -4
- package/node_modules/typebox/build/type/extends/enum.mjs +3 -2
- package/node_modules/typebox/build/type/extends/extends_left.d.mts +5 -7
- package/node_modules/typebox/build/type/extends/extends_left.mjs +24 -27
- package/node_modules/typebox/build/type/extends/extends_right.d.mts +7 -5
- package/node_modules/typebox/build/type/extends/extends_right.mjs +20 -15
- package/node_modules/typebox/build/type/extends/inference.mjs +1 -1
- package/node_modules/typebox/build/type/extends/object.d.mts +8 -1
- package/node_modules/typebox/build/type/extends/object.mjs +25 -3
- package/node_modules/typebox/build/type/extends/parameters.mjs +2 -2
- package/node_modules/typebox/build/type/extends/record.d.mts +13 -0
- package/node_modules/typebox/build/type/extends/record.mjs +23 -0
- package/node_modules/typebox/build/type/extends/template_literal.d.mts +3 -3
- package/node_modules/typebox/build/type/extends/template_literal.mjs +3 -3
- package/node_modules/typebox/build/type/extends/tuple.d.mts +3 -6
- package/node_modules/typebox/build/type/extends/tuple.mjs +6 -5
- package/node_modules/typebox/build/type/extends/union.mjs +2 -2
- package/node_modules/typebox/build/type/script/mapping.d.mts +84 -99
- package/node_modules/typebox/build/type/script/mapping.mjs +81 -85
- package/node_modules/typebox/build/type/script/parser.d.mts +40 -40
- package/node_modules/typebox/build/type/script/parser.mjs +22 -22
- package/node_modules/typebox/build/type/script/script.d.mts +3 -4
- package/node_modules/typebox/build/type/script/script.mjs +3 -2
- package/node_modules/typebox/build/type/script/token/internal/guard.d.mts +1 -1
- package/node_modules/typebox/build/type/script/token/internal/guard.mjs +1 -1
- package/node_modules/typebox/build/type/script/token/internal/take.mjs +1 -1
- package/node_modules/typebox/build/type/script/token/until.mjs +2 -2
- package/node_modules/typebox/build/type/types/_codec.d.mts +12 -12
- package/node_modules/typebox/build/type/types/_codec.mjs +0 -1
- package/node_modules/typebox/build/type/types/_immutable.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_immutable.mjs +2 -10
- package/node_modules/typebox/build/type/types/_optional.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_optional.mjs +2 -11
- package/node_modules/typebox/build/type/types/_readonly.d.mts +2 -9
- package/node_modules/typebox/build/type/types/_readonly.mjs +2 -10
- package/node_modules/typebox/build/type/types/_refine.d.mts +8 -10
- package/node_modules/typebox/build/type/types/_refine.mjs +1 -2
- package/node_modules/typebox/build/type/types/call.d.mts +3 -3
- package/node_modules/typebox/build/type/types/call.mjs +3 -2
- package/node_modules/typebox/build/type/types/deferred.d.mts +1 -0
- package/node_modules/typebox/build/type/types/deferred.mjs +1 -1
- package/node_modules/typebox/build/type/types/dependent.d.mts +17 -0
- package/node_modules/typebox/build/type/types/dependent.mjs +24 -0
- package/node_modules/typebox/build/type/types/enum.d.mts +3 -1
- package/node_modules/typebox/build/type/types/enum.mjs +5 -0
- package/node_modules/typebox/build/type/types/index.d.mts +1 -4
- package/node_modules/typebox/build/type/types/index.mjs +1 -4
- package/node_modules/typebox/build/type/types/number.d.mts +1 -1
- package/node_modules/typebox/build/type/types/number.mjs +1 -1
- package/node_modules/typebox/build/type/types/record.d.mts +13 -7
- package/node_modules/typebox/build/type/types/record.mjs +15 -9
- package/node_modules/typebox/build/type/types/static.d.mts +2 -5
- package/node_modules/typebox/build/typebox.d.mts +4 -8
- package/node_modules/typebox/build/typebox.mjs +4 -8
- package/node_modules/typebox/build/value/clean/clean.mjs +4 -2
- package/node_modules/typebox/build/value/clean/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/value/clean/from_type.mjs +8 -10
- package/node_modules/typebox/build/value/clean/from_union.d.mts +1 -1
- package/node_modules/typebox/build/value/clean/from_union.mjs +1 -2
- package/node_modules/typebox/build/value/clone/clone.mjs +2 -73
- package/node_modules/typebox/build/value/codec/decode.mjs +4 -2
- package/node_modules/typebox/build/value/codec/encode.mjs +4 -2
- package/node_modules/typebox/build/value/codec/from_array.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_object.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_record.mjs +2 -7
- package/node_modules/typebox/build/value/codec/from_tuple.mjs +1 -4
- package/node_modules/typebox/build/value/codec/from_union.mjs +2 -3
- package/node_modules/typebox/build/value/convert/from_enum.mjs +3 -4
- package/node_modules/typebox/build/value/convert/from_template_literal.d.mts +1 -1
- package/node_modules/typebox/build/value/convert/from_template_literal.mjs +2 -3
- package/node_modules/typebox/build/value/convert/from_type.mjs +19 -21
- package/node_modules/typebox/build/value/create/from_enum.mjs +2 -2
- package/node_modules/typebox/build/value/create/from_type.mjs +23 -31
- package/node_modules/typebox/build/value/default/from_object.mjs +1 -1
- package/node_modules/typebox/build/value/default/from_type.mjs +8 -10
- package/node_modules/typebox/build/value/index.d.mts +0 -1
- package/node_modules/typebox/build/value/index.mjs +0 -1
- package/node_modules/typebox/build/value/repair/from_enum.mjs +2 -3
- package/node_modules/typebox/build/value/repair/from_type.mjs +24 -22
- package/node_modules/typebox/build/value/shared/union_priority_sort.d.mts +6 -2
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +62 -26
- package/node_modules/typebox/build/value/value.d.mts +0 -1
- package/node_modules/typebox/build/value/value.mjs +0 -1
- package/node_modules/typebox/package.json +25 -25
- package/node_modules/typebox/readme.md +97 -80
- package/node_modules/undici-types/agent.d.ts +0 -2
- package/node_modules/undici-types/client.d.ts +25 -19
- package/node_modules/undici-types/dispatcher.d.ts +7 -33
- package/node_modules/undici-types/dispatcher1-wrapper.d.ts +7 -0
- package/node_modules/undici-types/fetch.d.ts +24 -4
- package/node_modules/undici-types/h2c-client.d.ts +6 -6
- package/node_modules/undici-types/handlers.d.ts +1 -2
- package/node_modules/undici-types/header.d.ts +5 -0
- package/node_modules/undici-types/index.d.ts +3 -1
- package/node_modules/undici-types/interceptors.d.ts +1 -1
- package/node_modules/undici-types/package.json +1 -1
- package/node_modules/undici-types/pool.d.ts +0 -2
- package/node_modules/undici-types/proxy-agent.d.ts +2 -2
- package/node_modules/undici-types/round-robin-pool.d.ts +0 -2
- package/node_modules/undici-types/snapshot-agent.d.ts +4 -0
- package/node_modules/undici-types/socks5-proxy-agent.d.ts +2 -2
- package/node_modules/undici-types/webidl.d.ts +0 -1
- package/npm-shrinkwrap.json +49 -41
- package/openclaw.plugin.json +12 -0
- package/package.json +5 -5
- package/node_modules/@cacheable/memory/dist/index.d.ts +0 -310
- package/node_modules/@cacheable/memory/dist/index.js +0 -807
- package/node_modules/@cacheable/utils/dist/index.d.ts +0 -307
- package/node_modules/@cacheable/utils/dist/index.js +0 -630
- package/node_modules/@types/node/compatibility/iterators.d.ts +0 -21
- package/node_modules/cacheable/dist/index.d.ts +0 -494
- package/node_modules/cacheable/dist/index.js +0 -1141
- package/node_modules/content-type/HISTORY.md +0 -29
- package/node_modules/content-type/index.js +0 -225
- package/node_modules/media-typer/HISTORY.md +0 -50
- package/node_modules/media-typer/index.js +0 -143
- package/node_modules/typebox/build/schema/engine/_guard.d.mts +0 -6
- package/node_modules/typebox/build/schema/engine/_guard.mjs +0 -26
- package/node_modules/typebox/build/schema/types/_guard.d.mts +0 -10
- package/node_modules/typebox/build/schema/types/_guard.mjs +0 -16
- package/node_modules/typebox/build/type/action/_optional.d.mts +0 -19
- package/node_modules/typebox/build/type/action/_optional.mjs +0 -40
- package/node_modules/typebox/build/type/action/_readonly.d.mts +0 -19
- package/node_modules/typebox/build/type/action/_readonly.mjs +0 -40
- package/node_modules/typebox/build/type/action/awaited.d.mts +0 -15
- package/node_modules/typebox/build/type/action/awaited.mjs +0 -15
- package/node_modules/typebox/build/type/action/options.d.mts +0 -11
- package/node_modules/typebox/build/type/action/options.mjs +0 -11
- package/node_modules/typebox/build/type/engine/awaited/instantiate.d.mts +0 -11
- package/node_modules/typebox/build/type/engine/awaited/instantiate.mjs +0 -20
- package/node_modules/typebox/build/type/engine/enum/enum_to_union.d.mts +0 -14
- package/node_modules/typebox/build/type/engine/enum/enum_to_union.mjs +0 -24
- package/node_modules/typebox/build/type/engine/options/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/options/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/options/instantiate.d.mts +0 -8
- package/node_modules/typebox/build/type/extends/async_iterator.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/async_iterator.mjs +0 -9
- package/node_modules/typebox/build/type/extends/iterator.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/iterator.mjs +0 -9
- package/node_modules/typebox/build/type/extends/promise.d.mts +0 -7
- package/node_modules/typebox/build/type/extends/promise.mjs +0 -9
- package/node_modules/typebox/build/type/types/async_iterator.d.mts +0 -20
- package/node_modules/typebox/build/type/types/async_iterator.mjs +0 -28
- package/node_modules/typebox/build/type/types/base.d.mts +0 -50
- package/node_modules/typebox/build/type/types/base.mjs +0 -84
- package/node_modules/typebox/build/type/types/iterator.d.mts +0 -20
- package/node_modules/typebox/build/type/types/iterator.mjs +0 -28
- package/node_modules/typebox/build/type/types/promise.d.mts +0 -21
- package/node_modules/typebox/build/type/types/promise.mjs +0 -29
- package/node_modules/typebox/build/value/clean/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/clean/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/convert/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/convert/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/create/from_async_iterator.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_async_iterator.mjs +0 -5
- package/node_modules/typebox/build/value/create/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_base.mjs +0 -4
- package/node_modules/typebox/build/value/create/from_iterator.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_iterator.mjs +0 -5
- package/node_modules/typebox/build/value/create/from_promise.d.mts +0 -2
- package/node_modules/typebox/build/value/create/from_promise.mjs +0 -5
- package/node_modules/typebox/build/value/default/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/default/from_base.mjs +0 -5
- package/node_modules/typebox/build/value/mutate/error.d.mts +0 -3
- package/node_modules/typebox/build/value/mutate/error.mjs +0 -6
- package/node_modules/typebox/build/value/mutate/from_array.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_array.mjs +0 -16
- package/node_modules/typebox/build/value/mutate/from_object.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_object.mjs +0 -40
- package/node_modules/typebox/build/value/mutate/from_unknown.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_unknown.mjs +0 -7
- package/node_modules/typebox/build/value/mutate/from_value.d.mts +0 -2
- package/node_modules/typebox/build/value/mutate/from_value.mjs +0 -12
- package/node_modules/typebox/build/value/mutate/index.d.mts +0 -1
- package/node_modules/typebox/build/value/mutate/index.mjs +0 -1
- package/node_modules/typebox/build/value/mutate/mutate.d.mts +0 -11
- package/node_modules/typebox/build/value/mutate/mutate.mjs +0 -41
- package/node_modules/typebox/build/value/repair/from_base.d.mts +0 -2
- package/node_modules/typebox/build/value/repair/from_base.mjs +0 -8
- package/dist/{approval-resolver-e1hAVRRy.js → approval-resolver-DF-lu8k5.js} +1 -1
- /package/node_modules/typebox/build/type/engine/{awaited → with}/index.d.mts +0 -0
- /package/node_modules/typebox/build/type/engine/{awaited → with}/index.mjs +0 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cacheable",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "High Performance Layer 1 / Layer 2 Caching with Keyv Storage",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.
|
|
7
|
-
"module": "./dist/index.
|
|
8
|
-
"types": "./dist/index.d.
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.mts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
11
|
"import": {
|
|
12
|
-
"types": "./dist/index.d.
|
|
13
|
-
"default": "./dist/index.
|
|
12
|
+
"types": "./dist/index.d.mts",
|
|
13
|
+
"default": "./dist/index.mjs"
|
|
14
14
|
},
|
|
15
15
|
"require": {
|
|
16
16
|
"types": "./dist/index.d.cts",
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
"@keyv/valkey": "^1.0.11",
|
|
32
32
|
"@qified/redis": "^0.10.1",
|
|
33
33
|
"lru-cache": "^11.3.6",
|
|
34
|
-
"
|
|
34
|
+
"tsdown": "^0.22.0",
|
|
35
35
|
"typescript": "^5.9.3"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"hookified": "^1.15.0",
|
|
39
39
|
"keyv": "^5.6.0",
|
|
40
40
|
"qified": "^0.10.1",
|
|
41
|
-
"@cacheable/memory": "^2.0
|
|
42
|
-
"@cacheable/utils": "^2.
|
|
41
|
+
"@cacheable/memory": "^2.2.0",
|
|
42
|
+
"@cacheable/utils": "^2.5.0"
|
|
43
43
|
},
|
|
44
44
|
"keywords": [
|
|
45
45
|
"cacheable",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"LICENSE"
|
|
73
73
|
],
|
|
74
74
|
"scripts": {
|
|
75
|
-
"build": "rimraf ./dist &&
|
|
75
|
+
"build": "rimraf ./dist && tsdown src/index.ts --format cjs,esm --dts --clean",
|
|
76
76
|
"lint": "biome check --write --error-on-warnings",
|
|
77
77
|
"test": "pnpm lint && vitest run --coverage",
|
|
78
78
|
"test:ci": "biome check --error-on-warnings && vitest run --coverage",
|
|
@@ -1,81 +1,55 @@
|
|
|
1
1
|
# content-type
|
|
2
2
|
|
|
3
|
-
[![NPM
|
|
4
|
-
[![NPM
|
|
5
|
-
[![
|
|
6
|
-
[![Build
|
|
7
|
-
[![
|
|
3
|
+
[![NPM version][npm-image]][npm-url]
|
|
4
|
+
[![NPM downloads][downloads-image]][downloads-url]
|
|
5
|
+
[![Build status][build-image]][build-url]
|
|
6
|
+
[![Build coverage][coverage-image]][coverage-url]
|
|
7
|
+
[![License][license-image]][license-url]
|
|
8
8
|
|
|
9
|
-
Create and parse HTTP Content-Type header
|
|
9
|
+
Create and parse HTTP `Content-Type` header.
|
|
10
10
|
|
|
11
11
|
## Installation
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
|
-
|
|
14
|
+
npm install content-type
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## API
|
|
18
18
|
|
|
19
19
|
```js
|
|
20
|
-
|
|
20
|
+
const contentType = require("content-type");
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
### contentType.parse(string)
|
|
23
|
+
### contentType.parse(string, options?)
|
|
24
24
|
|
|
25
25
|
```js
|
|
26
|
-
|
|
26
|
+
const obj = contentType.parse("image/svg+xml; charset=utf-8");
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
Parse a `Content-Type` header. This will return an object with the following
|
|
30
|
-
properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`):
|
|
29
|
+
Parse a `Content-Type` header. This will return an object with the following properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`):
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
- `type`: The media type. Example: `'image/svg+xml'`.
|
|
32
|
+
- `parameters`: An object of the parameters in the media type (parameter name is always lower case). Example: `{charset: 'utf-8'}`.
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
always lower case). Example: `{charset: 'utf-8'}`
|
|
34
|
+
The parser is lenient and does not error. You should validate `type` and `parameters` before trusting them.
|
|
37
35
|
|
|
38
|
-
|
|
36
|
+
#### Options
|
|
39
37
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
```js
|
|
43
|
-
var obj = contentType.parse(req)
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Parse the `Content-Type` header from the given `req`. Short-cut for
|
|
47
|
-
`contentType.parse(req.headers['content-type'])`.
|
|
48
|
-
|
|
49
|
-
Throws a `TypeError` if the `Content-Type` header is missing or invalid.
|
|
50
|
-
|
|
51
|
-
### contentType.parse(res)
|
|
52
|
-
|
|
53
|
-
```js
|
|
54
|
-
var obj = contentType.parse(res)
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Parse the `Content-Type` header set on the given `res`. Short-cut for
|
|
58
|
-
`contentType.parse(res.getHeader('content-type'))`.
|
|
59
|
-
|
|
60
|
-
Throws a `TypeError` if the `Content-Type` header is missing or invalid.
|
|
38
|
+
- `parameters` (default: `true`): Set to `false` to skip parameters.
|
|
61
39
|
|
|
62
40
|
### contentType.format(obj)
|
|
63
41
|
|
|
64
42
|
```js
|
|
65
|
-
|
|
66
|
-
type:
|
|
67
|
-
parameters: { charset:
|
|
68
|
-
})
|
|
43
|
+
const str = contentType.format({
|
|
44
|
+
type: "image/svg+xml",
|
|
45
|
+
parameters: { charset: "utf-8" },
|
|
46
|
+
});
|
|
69
47
|
```
|
|
70
48
|
|
|
71
|
-
Format an object into a `Content-Type` header. This will return a string of the
|
|
72
|
-
content type for the given object with the following properties (examples are
|
|
73
|
-
shown that produce the string `'image/svg+xml; charset=utf-8'`):
|
|
74
|
-
|
|
75
|
-
- `type`: The media type (will be lower-cased). Example: `'image/svg+xml'`
|
|
49
|
+
Format an object into a `Content-Type` header. This will return a string of the content type for the given object with the following properties (examples are shown that produce the string `'image/svg+xml; charset=utf-8'`):
|
|
76
50
|
|
|
77
|
-
|
|
78
|
-
|
|
51
|
+
- `type`: The media type. Example: `'image/svg+xml'`.
|
|
52
|
+
- `parameters`: An optional object of the parameters in the media type. Example: `{charset: 'utf-8'}`.
|
|
79
53
|
|
|
80
54
|
Throws a `TypeError` if the object contains an invalid type or parameter names.
|
|
81
55
|
|
|
@@ -83,12 +57,13 @@ Throws a `TypeError` if the object contains an invalid type or parameter names.
|
|
|
83
57
|
|
|
84
58
|
[MIT](LICENSE)
|
|
85
59
|
|
|
86
|
-
[
|
|
87
|
-
[ci-url]: https://github.com/jshttp/content-type/actions/workflows/ci.yml
|
|
88
|
-
[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/content-type/master
|
|
89
|
-
[coveralls-url]: https://coveralls.io/r/jshttp/content-type?branch=master
|
|
90
|
-
[node-image]: https://badgen.net/npm/node/content-type
|
|
91
|
-
[node-url]: https://nodejs.org/en/download
|
|
92
|
-
[npm-downloads-image]: https://badgen.net/npm/dm/content-type
|
|
60
|
+
[npm-image]: https://img.shields.io/npm/v/content-type
|
|
93
61
|
[npm-url]: https://npmjs.org/package/content-type
|
|
94
|
-
[
|
|
62
|
+
[downloads-image]: https://img.shields.io/npm/dm/content-type
|
|
63
|
+
[downloads-url]: https://npmjs.org/package/content-type
|
|
64
|
+
[build-image]: https://img.shields.io/github/actions/workflow/status/jshttp/content-type/ci.yml?branch=master
|
|
65
|
+
[build-url]: https://github.com/jshttp/content-type/actions/workflows/ci.yml?query=branch%3Amaster
|
|
66
|
+
[coverage-image]: https://img.shields.io/codecov/c/gh/jshttp/content-type
|
|
67
|
+
[coverage-url]: https://codecov.io/gh/jshttp/content-type
|
|
68
|
+
[license-image]: http://img.shields.io/npm/l/content-type.svg?style=flat
|
|
69
|
+
[license-url]: LICENSE
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* content-type
|
|
3
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
4
|
+
* MIT Licensed
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The content type object contains a type string and optional parameters.
|
|
8
|
+
*/
|
|
9
|
+
export interface ContentType {
|
|
10
|
+
type: string;
|
|
11
|
+
parameters: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Format an object into a `Content-Type` header.
|
|
15
|
+
*/
|
|
16
|
+
export declare function format(obj: Partial<ContentType>): string;
|
|
17
|
+
/**
|
|
18
|
+
* Options for parsing a `Content-Type` header.
|
|
19
|
+
*/
|
|
20
|
+
export interface ParseOptions {
|
|
21
|
+
parameters?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Parse a `Content-Type` header.
|
|
25
|
+
*/
|
|
26
|
+
export declare function parse(header: string, options?: ParseOptions): ContentType;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* content-type
|
|
4
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
5
|
+
* MIT Licensed
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.format = format;
|
|
9
|
+
exports.parse = parse;
|
|
10
|
+
const TEXT_REGEXP = /^[\u0009\u0020-\u007e\u0080-\u00ff]*$/;
|
|
11
|
+
const TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
12
|
+
/**
|
|
13
|
+
* RegExp to match chars that must be quoted-pair in RFC 9110 sec 5.6.4
|
|
14
|
+
*/
|
|
15
|
+
const QUOTE_REGEXP = /[\\"]/g;
|
|
16
|
+
/**
|
|
17
|
+
* RegExp to match type in RFC 9110 sec 8.3.1
|
|
18
|
+
*
|
|
19
|
+
* media-type = type "/" subtype
|
|
20
|
+
* type = token
|
|
21
|
+
* subtype = token
|
|
22
|
+
*/
|
|
23
|
+
const TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
24
|
+
/**
|
|
25
|
+
* Null object perf optimization. Faster than `Object.create(null)` and `{ __proto__: null }`.
|
|
26
|
+
*/
|
|
27
|
+
const NullObject = /* @__PURE__ */ (() => {
|
|
28
|
+
const C = function () { };
|
|
29
|
+
C.prototype = Object.create(null);
|
|
30
|
+
return C;
|
|
31
|
+
})();
|
|
32
|
+
/**
|
|
33
|
+
* Format an object into a `Content-Type` header.
|
|
34
|
+
*/
|
|
35
|
+
function format(obj) {
|
|
36
|
+
const { type, parameters } = obj;
|
|
37
|
+
if (!type || !TYPE_REGEXP.test(type)) {
|
|
38
|
+
throw new TypeError(`Invalid type: ${type}`);
|
|
39
|
+
}
|
|
40
|
+
let result = type;
|
|
41
|
+
if (parameters) {
|
|
42
|
+
for (const param of Object.keys(parameters)) {
|
|
43
|
+
if (!TOKEN_REGEXP.test(param)) {
|
|
44
|
+
throw new TypeError(`Invalid parameter name: ${param}`);
|
|
45
|
+
}
|
|
46
|
+
result += `; ${param}=${qstring(parameters[param])}`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Parse a `Content-Type` header.
|
|
53
|
+
*/
|
|
54
|
+
function parse(header, options) {
|
|
55
|
+
const len = header.length;
|
|
56
|
+
let index = skipOWS(header, 0, len);
|
|
57
|
+
const valueStart = index;
|
|
58
|
+
index = skipValue(header, index, len);
|
|
59
|
+
const valueEnd = trailingOWS(header, valueStart, index);
|
|
60
|
+
const type = header.slice(valueStart, valueEnd).toLowerCase();
|
|
61
|
+
const parameters = options?.parameters === false
|
|
62
|
+
? new NullObject()
|
|
63
|
+
: parseParameters(header, index, len);
|
|
64
|
+
return { type, parameters };
|
|
65
|
+
}
|
|
66
|
+
const SP = 32; // " "
|
|
67
|
+
const HTAB = 9; // "\t"
|
|
68
|
+
const SEMI = 59; // ";"
|
|
69
|
+
const EQ = 61; // "="
|
|
70
|
+
const DQUOTE = 34; // '"'
|
|
71
|
+
const BSLASH = 92; // "\\"
|
|
72
|
+
/**
|
|
73
|
+
* Parses the parameters of a `Content-Type` header starting at the given index.
|
|
74
|
+
*/
|
|
75
|
+
function parseParameters(header, index, len) {
|
|
76
|
+
const parameters = new NullObject();
|
|
77
|
+
parameter: while (index < len) {
|
|
78
|
+
index = skipOWS(header, index + 1 /* Skip over ; */, len);
|
|
79
|
+
const keyStart = index;
|
|
80
|
+
while (index < len) {
|
|
81
|
+
const code = header.charCodeAt(index);
|
|
82
|
+
if (code === SEMI)
|
|
83
|
+
continue parameter;
|
|
84
|
+
if (code === EQ) {
|
|
85
|
+
const keyEnd = trailingOWS(header, keyStart, index);
|
|
86
|
+
const key = header.slice(keyStart, keyEnd).toLowerCase();
|
|
87
|
+
index = skipOWS(header, index + 1, len);
|
|
88
|
+
if (index < len && header.charCodeAt(index) === DQUOTE) {
|
|
89
|
+
index++;
|
|
90
|
+
let value = "";
|
|
91
|
+
while (index < len) {
|
|
92
|
+
const code = header.charCodeAt(index++);
|
|
93
|
+
if (code === DQUOTE) {
|
|
94
|
+
index = skipValue(header, index, len);
|
|
95
|
+
if (parameters[key] === undefined)
|
|
96
|
+
parameters[key] = value;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (code === BSLASH && index < len) {
|
|
100
|
+
value += header[index++];
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
value += String.fromCharCode(code);
|
|
104
|
+
}
|
|
105
|
+
continue parameter;
|
|
106
|
+
}
|
|
107
|
+
const valueStart = index;
|
|
108
|
+
index = skipValue(header, index, len);
|
|
109
|
+
if (parameters[key] === undefined) {
|
|
110
|
+
const valueEnd = trailingOWS(header, valueStart, index);
|
|
111
|
+
parameters[key] = header.slice(valueStart, valueEnd);
|
|
112
|
+
}
|
|
113
|
+
continue parameter;
|
|
114
|
+
}
|
|
115
|
+
index++;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return parameters;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Skip over characters until a semicolon.
|
|
122
|
+
*/
|
|
123
|
+
function skipValue(str, index, len) {
|
|
124
|
+
while (index < len) {
|
|
125
|
+
const char = str.charCodeAt(index);
|
|
126
|
+
if (char === SEMI)
|
|
127
|
+
break;
|
|
128
|
+
index++;
|
|
129
|
+
}
|
|
130
|
+
return index;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Skip optional whitespace (OWS) in an HTTP header value.
|
|
134
|
+
*
|
|
135
|
+
* OWS is defined in RFC 9110 sec 5.6.3 as SP (" ") or HTAB ("\t").
|
|
136
|
+
*/
|
|
137
|
+
function skipOWS(header, index, len) {
|
|
138
|
+
while (index < len) {
|
|
139
|
+
const char = header.charCodeAt(index);
|
|
140
|
+
if (char !== SP && char !== HTAB)
|
|
141
|
+
break;
|
|
142
|
+
index++;
|
|
143
|
+
}
|
|
144
|
+
return index;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Trim optional whitespace (OWS) from the end of a substring.
|
|
148
|
+
*
|
|
149
|
+
* OWS is defined in RFC 9110 sec 5.6.3 as SP (" ") or HTAB ("\t").
|
|
150
|
+
*/
|
|
151
|
+
function trailingOWS(header, start, end) {
|
|
152
|
+
while (end > start) {
|
|
153
|
+
const char = header.charCodeAt(end - 1);
|
|
154
|
+
if (char !== SP && char !== HTAB)
|
|
155
|
+
break;
|
|
156
|
+
end--;
|
|
157
|
+
}
|
|
158
|
+
return end;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Serialize a parameter value.
|
|
162
|
+
*/
|
|
163
|
+
function qstring(str) {
|
|
164
|
+
if (TOKEN_REGEXP.test(str))
|
|
165
|
+
return str;
|
|
166
|
+
if (TEXT_REGEXP.test(str))
|
|
167
|
+
return `"${str.replace(QUOTE_REGEXP, "\\$&")}"`;
|
|
168
|
+
throw new TypeError(`Invalid parameter value: ${str}`);
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAwCH,wBAoBC;AAYD,sBAcC;AApFD,MAAM,WAAW,GAAG,uCAAuC,CAAC;AAC5D,MAAM,YAAY,GAAG,+BAA+B,CAAC;AAErD;;GAEG;AACH,MAAM,YAAY,GAAG,QAAQ,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,WAAW,GACf,4DAA4D,CAAC;AAE/D;;GAEG;AACH,MAAM,UAAU,GAAG,eAAe,CAAC,CAAC,GAAG,EAAE;IACvC,MAAM,CAAC,GAAG,cAAa,CAAC,CAAC;IACzB,CAAC,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,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,GAAG,CAAC;IAE3E,MAAM,IAAI,SAAS,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC;AACzD,CAAC","sourcesContent":["/*!\n * content-type\n * Copyright(c) 2015 Douglas Christopher Wilson\n * MIT Licensed\n */\n\nconst TEXT_REGEXP = /^[\\u0009\\u0020-\\u007e\\u0080-\\u00ff]*$/;\nconst TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * RegExp to match chars that must be quoted-pair in RFC 9110 sec 5.6.4\n */\nconst QUOTE_REGEXP = /[\\\\\"]/g;\n\n/**\n * RegExp to match type in RFC 9110 sec 8.3.1\n *\n * media-type = type \"/\" subtype\n * type = token\n * subtype = token\n */\nconst TYPE_REGEXP =\n /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;\n\n/**\n * Null object perf optimization. Faster than `Object.create(null)` and `{ __proto__: null }`.\n */\nconst NullObject = /* @__PURE__ */ (() => {\n const C = function () {};\n C.prototype = Object.create(null);\n return C;\n})() as unknown as { new (): any };\n\n/**\n * The content type object contains a type string and optional parameters.\n */\nexport interface ContentType {\n type: string;\n parameters: Record<string, string>;\n}\n\n/**\n * Format an object into a `Content-Type` header.\n */\nexport function format(obj: Partial<ContentType>): string {\n const { type, parameters } = obj;\n\n if (!type || !TYPE_REGEXP.test(type)) {\n throw new TypeError(`Invalid type: ${type}`);\n }\n\n let result = type;\n\n if (parameters) {\n for (const param of Object.keys(parameters)) {\n if (!TOKEN_REGEXP.test(param)) {\n throw new TypeError(`Invalid parameter name: ${param}`);\n }\n\n result += `; ${param}=${qstring(parameters[param])}`;\n }\n }\n\n return result;\n}\n\n/**\n * Options for parsing a `Content-Type` header.\n */\nexport interface ParseOptions {\n parameters?: boolean;\n}\n\n/**\n * Parse a `Content-Type` header.\n */\nexport function parse(header: string, options?: ParseOptions): ContentType {\n const len = header.length;\n let index = skipOWS(header, 0, len);\n\n const valueStart = index;\n index = skipValue(header, index, len);\n const valueEnd = trailingOWS(header, valueStart, index);\n const type = header.slice(valueStart, valueEnd).toLowerCase();\n const parameters =\n options?.parameters === false\n ? new NullObject()\n : parseParameters(header, index, len);\n\n return { type, parameters };\n}\n\nconst SP = 32; // \" \"\nconst HTAB = 9; // \"\\t\"\nconst SEMI = 59; // \";\"\nconst EQ = 61; // \"=\"\nconst DQUOTE = 34; // '\"'\nconst BSLASH = 92; // \"\\\\\"\n\n/**\n * Parses the parameters of a `Content-Type` header starting at the given index.\n */\nfunction parseParameters(\n header: string,\n index: number,\n len: number,\n): Record<string, string> {\n const parameters: Record<string, string> = new NullObject();\n\n parameter: while (index < len) {\n index = skipOWS(header, index + 1 /* Skip over ; */, len);\n\n const keyStart = index;\n\n while (index < len) {\n const code = header.charCodeAt(index);\n if (code === SEMI) continue parameter;\n\n if (code === EQ) {\n const keyEnd = trailingOWS(header, keyStart, index);\n const key = header.slice(keyStart, keyEnd).toLowerCase();\n\n index = skipOWS(header, index + 1, len);\n\n if (index < len && header.charCodeAt(index) === DQUOTE) {\n index++;\n\n let value = \"\";\n while (index < len) {\n const code = header.charCodeAt(index++);\n if (code === DQUOTE) {\n index = skipValue(header, index, len);\n if (parameters[key] === undefined) parameters[key] = value;\n break;\n }\n\n if (code === BSLASH && index < len) {\n value += header[index++];\n continue;\n }\n\n value += String.fromCharCode(code);\n }\n\n continue parameter;\n }\n\n const valueStart = index;\n index = skipValue(header, index, len);\n\n if (parameters[key] === undefined) {\n const valueEnd = trailingOWS(header, valueStart, index);\n parameters[key] = header.slice(valueStart, valueEnd);\n }\n\n continue parameter;\n }\n\n index++;\n }\n }\n\n return parameters;\n}\n\n/**\n * Skip over characters until a semicolon.\n */\nfunction skipValue(str: string, index: number, len: number): number {\n while (index < len) {\n const char = str.charCodeAt(index);\n if (char === SEMI) break;\n index++;\n }\n return index;\n}\n\n/**\n * Skip optional whitespace (OWS) in an HTTP header value.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction skipOWS(header: string, index: number, len: number): number {\n while (index < len) {\n const char = header.charCodeAt(index);\n if (char !== SP && char !== HTAB) break;\n index++;\n }\n return index;\n}\n\n/**\n * Trim optional whitespace (OWS) from the end of a substring.\n *\n * OWS is defined in RFC 9110 sec 5.6.3 as SP (\" \") or HTAB (\"\\t\").\n */\nfunction trailingOWS(header: string, start: number, end: number): number {\n while (end > start) {\n const char = header.charCodeAt(end - 1);\n if (char !== SP && char !== HTAB) break;\n end--;\n }\n return end;\n}\n\n/**\n * Serialize a parameter value.\n */\nfunction qstring(str: string): string {\n if (TOKEN_REGEXP.test(str)) return str;\n if (TEXT_REGEXP.test(str)) return `\"${str.replace(QUOTE_REGEXP, \"\\\\$&\")}\"`;\n\n throw new TypeError(`Invalid parameter value: ${str}`);\n}\n"]}
|
|
@@ -1,42 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "content-type",
|
|
3
|
+
"version": "2.0.0",
|
|
3
4
|
"description": "Create and parse HTTP Content-Type header",
|
|
4
|
-
"version": "1.0.5",
|
|
5
|
-
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
|
|
6
|
-
"license": "MIT",
|
|
7
5
|
"keywords": [
|
|
8
6
|
"content-type",
|
|
9
7
|
"http",
|
|
10
8
|
"req",
|
|
11
9
|
"res",
|
|
12
|
-
"rfc7231"
|
|
10
|
+
"rfc7231",
|
|
11
|
+
"rfc9110"
|
|
13
12
|
],
|
|
14
13
|
"repository": "jshttp/content-type",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"eslint-config-standard": "15.0.1",
|
|
19
|
-
"eslint-plugin-import": "2.27.5",
|
|
20
|
-
"eslint-plugin-node": "11.1.0",
|
|
21
|
-
"eslint-plugin-promise": "6.1.1",
|
|
22
|
-
"eslint-plugin-standard": "4.1.0",
|
|
23
|
-
"mocha": "10.2.0",
|
|
24
|
-
"nyc": "15.1.0"
|
|
14
|
+
"funding": {
|
|
15
|
+
"type": "opencollective",
|
|
16
|
+
"url": "https://opencollective.com/express"
|
|
25
17
|
},
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
|
|
20
|
+
"type": "commonjs",
|
|
21
|
+
"exports": "./dist/index.js",
|
|
22
|
+
"main": "./dist/index.js",
|
|
23
|
+
"typings": "./dist/index.d.ts",
|
|
26
24
|
"files": [
|
|
27
|
-
"
|
|
28
|
-
"HISTORY.md",
|
|
29
|
-
"README.md",
|
|
30
|
-
"index.js"
|
|
25
|
+
"dist/"
|
|
31
26
|
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"bench": "vitest bench",
|
|
29
|
+
"build": "ts-scripts build",
|
|
30
|
+
"format": "ts-scripts format",
|
|
31
|
+
"prepare": "ts-scripts install && npm run build",
|
|
32
|
+
"specs": "ts-scripts specs",
|
|
33
|
+
"test": "ts-scripts test"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@borderless/ts-scripts": "^0.15.0",
|
|
37
|
+
"@vitest/coverage-v8": "^3.0.5",
|
|
38
|
+
"typescript": "^5.7.3",
|
|
39
|
+
"vitest": "^3.2.4"
|
|
40
|
+
},
|
|
32
41
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
42
|
+
"node": ">=18"
|
|
34
43
|
},
|
|
35
|
-
"scripts": {
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
44
|
+
"ts-scripts": {
|
|
45
|
+
"dist": [
|
|
46
|
+
"dist"
|
|
47
|
+
],
|
|
48
|
+
"project": [
|
|
49
|
+
"tsconfig.build.json"
|
|
50
|
+
]
|
|
41
51
|
}
|
|
42
52
|
}
|
|
@@ -2,17 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
[![NPM Version][npm-version-image]][npm-url]
|
|
4
4
|
[![NPM Downloads][npm-downloads-image]][npm-url]
|
|
5
|
-
[![
|
|
6
|
-
[![
|
|
7
|
-
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
5
|
+
[![Build Status][ci-image]][ci-url]
|
|
6
|
+
[![Coverage Status][coverage-image]][coverage-url]
|
|
8
7
|
|
|
9
8
|
Simple RFC 6838 media type parser.
|
|
10
9
|
|
|
11
|
-
This module will parse a given media type into
|
|
10
|
+
This module will parse a given media type into its component parts, like type,
|
|
12
11
|
subtype, and suffix. A formatter is also provided to put them back together and
|
|
13
12
|
the two can be combined to normalize media types into a canonical form.
|
|
14
13
|
|
|
15
|
-
If you are looking to parse the string that represents a media type and
|
|
14
|
+
If you are looking to parse the string that represents a media type and its
|
|
16
15
|
parameters in HTTP (for example, the `Content-Type` header), use the
|
|
17
16
|
[content-type module](https://www.npmjs.com/package/content-type).
|
|
18
17
|
|
|
@@ -28,37 +27,28 @@ $ npm install media-typer
|
|
|
28
27
|
|
|
29
28
|
## API
|
|
30
29
|
|
|
31
|
-
<!-- eslint-disable no-unused-vars -->
|
|
32
|
-
|
|
33
30
|
```js
|
|
34
|
-
|
|
31
|
+
import * as typer from "media-typer";
|
|
35
32
|
```
|
|
36
33
|
|
|
37
34
|
### typer.parse(string)
|
|
38
35
|
|
|
39
|
-
<!-- eslint-disable no-undef, no-unused-vars -->
|
|
40
|
-
|
|
41
36
|
```js
|
|
42
|
-
|
|
37
|
+
const obj = typer.parse("image/svg+xml");
|
|
43
38
|
```
|
|
44
39
|
|
|
45
|
-
Parse a media type string. This will return an object with the following
|
|
46
|
-
properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`):
|
|
47
|
-
|
|
48
|
-
- `type`: The type of the media type (always lower case). Example: `'image'`
|
|
40
|
+
Parse a media type string. This will return an object with the following properties:
|
|
49
41
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
42
|
+
- `type`: The type of the media type (always lower case). Example: `'image'`
|
|
43
|
+
- `subtype`: The subtype of the media type (always lower case). Example: `'svg'`
|
|
44
|
+
- `suffix`: Optional suffix of the media type (always lower case). Example: `'xml'`
|
|
53
45
|
|
|
54
46
|
If the given type string is invalid, then a `TypeError` is thrown.
|
|
55
47
|
|
|
56
48
|
### typer.format(obj)
|
|
57
49
|
|
|
58
|
-
<!-- eslint-disable no-undef, no-unused-vars -->
|
|
59
|
-
|
|
60
50
|
```js
|
|
61
|
-
|
|
51
|
+
const obj = typer.format({ type: "image", subtype: "svg", suffix: "xml" });
|
|
62
52
|
```
|
|
63
53
|
|
|
64
54
|
Format an object into a media type string. This will return a string of the
|
|
@@ -69,25 +59,21 @@ If any of the given object values are invalid, then a `TypeError` is thrown.
|
|
|
69
59
|
|
|
70
60
|
### typer.test(string)
|
|
71
61
|
|
|
72
|
-
<!-- eslint-disable no-undef, no-unused-vars -->
|
|
73
|
-
|
|
74
62
|
```js
|
|
75
|
-
|
|
63
|
+
const valid = typer.test("image/svg+xml");
|
|
76
64
|
```
|
|
77
65
|
|
|
78
|
-
Validate a media type string. This will return `true`
|
|
66
|
+
Validate a media type string. This will return `true` if the string is a well-
|
|
79
67
|
formatted media type, or `false` otherwise.
|
|
80
68
|
|
|
81
69
|
## License
|
|
82
70
|
|
|
83
71
|
[MIT](LICENSE)
|
|
84
72
|
|
|
85
|
-
[
|
|
86
|
-
[
|
|
87
|
-
[
|
|
88
|
-
[
|
|
89
|
-
[npm-downloads-image]: https://
|
|
73
|
+
[ci-image]: https://img.shields.io/github/actions/workflow/status/jshttp/media-typer/ci.yml
|
|
74
|
+
[ci-url]: https://github.com/jshttp/media-typer/actions/workflows/ci.yml?query=branch%3Amaster
|
|
75
|
+
[coverage-image]: https://img.shields.io/codecov/c/github/jshttp/media-typer/master
|
|
76
|
+
[coverage-url]: https://app.codecov.io/gh/jshttp/media-typer
|
|
77
|
+
[npm-downloads-image]: https://img.shields.io/npm/dm/media-typer
|
|
90
78
|
[npm-url]: https://npmjs.org/package/media-typer
|
|
91
|
-
[npm-version-image]: https://
|
|
92
|
-
[travis-image]: https://badgen.net/travis/jshttp/media-typer/master
|
|
93
|
-
[travis-url]: https://travis-ci.org/jshttp/media-typer
|
|
79
|
+
[npm-version-image]: https://img.shields.io/npm/v/media-typer
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media type object.
|
|
3
|
+
*/
|
|
4
|
+
export interface MediaType {
|
|
5
|
+
/**
|
|
6
|
+
* The type of the media type.
|
|
7
|
+
*/
|
|
8
|
+
type: string;
|
|
9
|
+
/**
|
|
10
|
+
* The subtype of the media type.
|
|
11
|
+
*/
|
|
12
|
+
subtype: string;
|
|
13
|
+
/**
|
|
14
|
+
* The structured syntax suffix of the media type.
|
|
15
|
+
*/
|
|
16
|
+
suffix?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Format object to media type.
|
|
20
|
+
*/
|
|
21
|
+
export declare function format(obj: MediaType): string;
|
|
22
|
+
/**
|
|
23
|
+
* Parse media type to object.
|
|
24
|
+
*/
|
|
25
|
+
export declare function parse(str: string): MediaType;
|
|
26
|
+
/**
|
|
27
|
+
* Test media type.
|
|
28
|
+
*/
|
|
29
|
+
export declare function test(str: string): boolean;
|