pull-request-split-advisor 3.1.2
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/LICENSE +52 -0
- package/README.md +168 -0
- package/dist/ai/config-wizard.js +282 -0
- package/dist/ai/enricher.js +290 -0
- package/dist/ai/prompts.js +231 -0
- package/dist/ai/provider.js +265 -0
- package/dist/cli.js +442 -0
- package/dist/config/config.js +315 -0
- package/dist/config/default-config.js +223 -0
- package/dist/core/blocks.js +145 -0
- package/dist/core/commit-planner.js +273 -0
- package/dist/core/dependency.js +284 -0
- package/dist/core/file-stats.js +341 -0
- package/dist/core/history.js +72 -0
- package/dist/core/planner.js +25 -0
- package/dist/core/scoring.js +166 -0
- package/dist/core/strategy.js +486 -0
- package/dist/git/branch-naming.js +120 -0
- package/dist/git/executor.js +378 -0
- package/dist/git/git.js +239 -0
- package/dist/output/report-styles.generated.js +10 -0
- package/dist/output/report.js +726 -0
- package/dist/output/ui.js +417 -0
- package/dist/shared/constants.js +59 -0
- package/dist/shared/types.js +7 -0
- package/dist/shared/utils.js +73 -0
- package/node_modules/@colors/colors/LICENSE +26 -0
- package/node_modules/@colors/colors/README.md +219 -0
- package/node_modules/@colors/colors/examples/normal-usage.js +83 -0
- package/node_modules/@colors/colors/examples/safe-string.js +80 -0
- package/node_modules/@colors/colors/index.d.ts +136 -0
- package/node_modules/@colors/colors/lib/colors.js +211 -0
- package/node_modules/@colors/colors/lib/custom/trap.js +46 -0
- package/node_modules/@colors/colors/lib/custom/zalgo.js +110 -0
- package/node_modules/@colors/colors/lib/extendStringPrototype.js +110 -0
- package/node_modules/@colors/colors/lib/index.js +13 -0
- package/node_modules/@colors/colors/lib/maps/america.js +10 -0
- package/node_modules/@colors/colors/lib/maps/rainbow.js +12 -0
- package/node_modules/@colors/colors/lib/maps/random.js +11 -0
- package/node_modules/@colors/colors/lib/maps/zebra.js +5 -0
- package/node_modules/@colors/colors/lib/styles.js +95 -0
- package/node_modules/@colors/colors/lib/system/has-flag.js +35 -0
- package/node_modules/@colors/colors/lib/system/supports-colors.js +151 -0
- package/node_modules/@colors/colors/package.json +45 -0
- package/node_modules/@colors/colors/safe.d.ts +48 -0
- package/node_modules/@colors/colors/safe.js +10 -0
- package/node_modules/@colors/colors/themes/generic-logging.js +12 -0
- package/node_modules/ansi-align/LICENSE +13 -0
- package/node_modules/ansi-align/README.md +80 -0
- package/node_modules/ansi-align/index.js +61 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/license +9 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/README.md +73 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/es2015/index.js +6 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/es2015/text.js +6 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/index.d.ts +23 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/index.js +6 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/package.json +50 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/text.js +6 -0
- package/node_modules/ansi-align/node_modules/string-width/index.d.ts +29 -0
- package/node_modules/ansi-align/node_modules/string-width/index.js +47 -0
- package/node_modules/ansi-align/node_modules/string-width/license +9 -0
- package/node_modules/ansi-align/node_modules/string-width/package.json +56 -0
- package/node_modules/ansi-align/node_modules/string-width/readme.md +50 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/license +9 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/ansi-align/package.json +43 -0
- package/node_modules/ansi-regex/index.d.ts +33 -0
- package/node_modules/ansi-regex/index.js +14 -0
- package/node_modules/ansi-regex/license +9 -0
- package/node_modules/ansi-regex/package.json +61 -0
- package/node_modules/ansi-regex/readme.md +66 -0
- package/node_modules/ansi-styles/index.d.ts +236 -0
- package/node_modules/ansi-styles/index.js +223 -0
- package/node_modules/ansi-styles/license +9 -0
- package/node_modules/ansi-styles/package.json +54 -0
- package/node_modules/ansi-styles/readme.md +173 -0
- package/node_modules/boxen/index.d.ts +267 -0
- package/node_modules/boxen/index.js +376 -0
- package/node_modules/boxen/license +9 -0
- package/node_modules/boxen/package.json +69 -0
- package/node_modules/boxen/readme.md +300 -0
- package/node_modules/camelcase/index.d.ts +102 -0
- package/node_modules/camelcase/index.js +110 -0
- package/node_modules/camelcase/license +9 -0
- package/node_modules/camelcase/package.json +47 -0
- package/node_modules/camelcase/readme.md +135 -0
- package/node_modules/chalk/license +9 -0
- package/node_modules/chalk/package.json +83 -0
- package/node_modules/chalk/readme.md +297 -0
- package/node_modules/chalk/source/index.d.ts +325 -0
- package/node_modules/chalk/source/index.js +225 -0
- package/node_modules/chalk/source/utilities.js +33 -0
- package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
- package/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
- package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
- package/node_modules/chalk/source/vendor/supports-color/browser.js +34 -0
- package/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/node_modules/chalk/source/vendor/supports-color/index.js +190 -0
- package/node_modules/cli-boxes/boxes.json +82 -0
- package/node_modules/cli-boxes/index.d.ts +127 -0
- package/node_modules/cli-boxes/index.js +6 -0
- package/node_modules/cli-boxes/license +9 -0
- package/node_modules/cli-boxes/package.json +42 -0
- package/node_modules/cli-boxes/readme.md +115 -0
- package/node_modules/cli-table3/LICENSE +21 -0
- package/node_modules/cli-table3/README.md +236 -0
- package/node_modules/cli-table3/index.d.ts +96 -0
- package/node_modules/cli-table3/index.js +1 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/license +9 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/README.md +73 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/es2015/index.js +6 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/es2015/text.js +6 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/index.d.ts +23 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/index.js +6 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/package.json +50 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/text.js +6 -0
- package/node_modules/cli-table3/node_modules/string-width/index.d.ts +29 -0
- package/node_modules/cli-table3/node_modules/string-width/index.js +47 -0
- package/node_modules/cli-table3/node_modules/string-width/license +9 -0
- package/node_modules/cli-table3/node_modules/string-width/package.json +56 -0
- package/node_modules/cli-table3/node_modules/string-width/readme.md +50 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/license +9 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/cli-table3/package.json +100 -0
- package/node_modules/cli-table3/src/cell.js +409 -0
- package/node_modules/cli-table3/src/debug.js +28 -0
- package/node_modules/cli-table3/src/layout-manager.js +254 -0
- package/node_modules/cli-table3/src/table.js +106 -0
- package/node_modules/cli-table3/src/utils.js +344 -0
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +1157 -0
- package/node_modules/commander/esm.mjs +16 -0
- package/node_modules/commander/index.js +24 -0
- package/node_modules/commander/lib/argument.js +149 -0
- package/node_modules/commander/lib/command.js +2509 -0
- package/node_modules/commander/lib/error.js +39 -0
- package/node_modules/commander/lib/help.js +520 -0
- package/node_modules/commander/lib/option.js +330 -0
- package/node_modules/commander/lib/suggestSimilar.js +101 -0
- package/node_modules/commander/package-support.json +16 -0
- package/node_modules/commander/package.json +84 -0
- package/node_modules/commander/typings/esm.d.mts +3 -0
- package/node_modules/commander/typings/index.d.ts +969 -0
- package/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/emoji-regex/README.md +107 -0
- package/node_modules/emoji-regex/index.d.ts +3 -0
- package/node_modules/emoji-regex/index.js +4 -0
- package/node_modules/emoji-regex/index.mjs +4 -0
- package/node_modules/emoji-regex/package.json +45 -0
- package/node_modules/get-east-asian-width/index.d.ts +60 -0
- package/node_modules/get-east-asian-width/index.js +30 -0
- package/node_modules/get-east-asian-width/license +9 -0
- package/node_modules/get-east-asian-width/lookup-data.js +18 -0
- package/node_modules/get-east-asian-width/lookup.js +135 -0
- package/node_modules/get-east-asian-width/package.json +71 -0
- package/node_modules/get-east-asian-width/readme.md +65 -0
- package/node_modules/get-east-asian-width/utilities.js +24 -0
- package/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
- package/node_modules/is-fullwidth-code-point/index.js +50 -0
- package/node_modules/is-fullwidth-code-point/license +9 -0
- package/node_modules/is-fullwidth-code-point/package.json +42 -0
- package/node_modules/is-fullwidth-code-point/readme.md +39 -0
- package/node_modules/isbinaryfile/LICENSE.txt +22 -0
- package/node_modules/isbinaryfile/README.md +70 -0
- package/node_modules/isbinaryfile/lib/index.d.ts +3 -0
- package/node_modules/isbinaryfile/lib/index.js +256 -0
- package/node_modules/isbinaryfile/package.json +64 -0
- package/node_modules/string-width/index.d.ts +39 -0
- package/node_modules/string-width/index.js +82 -0
- package/node_modules/string-width/license +9 -0
- package/node_modules/string-width/package.json +64 -0
- package/node_modules/string-width/readme.md +66 -0
- package/node_modules/strip-ansi/index.d.ts +15 -0
- package/node_modules/strip-ansi/index.js +19 -0
- package/node_modules/strip-ansi/license +9 -0
- package/node_modules/strip-ansi/package.json +59 -0
- package/node_modules/strip-ansi/readme.md +37 -0
- package/node_modules/type-fest/index.d.ts +178 -0
- package/node_modules/type-fest/license-cc0 +121 -0
- package/node_modules/type-fest/license-mit +9 -0
- package/node_modules/type-fest/package.json +91 -0
- package/node_modules/type-fest/readme.md +1060 -0
- package/node_modules/type-fest/source/all-union-fields.d.ts +88 -0
- package/node_modules/type-fest/source/and.d.ts +25 -0
- package/node_modules/type-fest/source/array-indices.d.ts +23 -0
- package/node_modules/type-fest/source/array-slice.d.ts +109 -0
- package/node_modules/type-fest/source/array-splice.d.ts +99 -0
- package/node_modules/type-fest/source/array-tail.d.ts +76 -0
- package/node_modules/type-fest/source/array-values.d.ts +22 -0
- package/node_modules/type-fest/source/arrayable.d.ts +29 -0
- package/node_modules/type-fest/source/async-return-type.d.ts +23 -0
- package/node_modules/type-fest/source/asyncify.d.ts +32 -0
- package/node_modules/type-fest/source/basic.d.ts +68 -0
- package/node_modules/type-fest/source/camel-case.d.ts +89 -0
- package/node_modules/type-fest/source/camel-cased-properties-deep.d.ts +97 -0
- package/node_modules/type-fest/source/camel-cased-properties.d.ts +43 -0
- package/node_modules/type-fest/source/conditional-except.d.ts +45 -0
- package/node_modules/type-fest/source/conditional-keys.d.ts +47 -0
- package/node_modules/type-fest/source/conditional-pick-deep.d.ts +118 -0
- package/node_modules/type-fest/source/conditional-pick.d.ts +44 -0
- package/node_modules/type-fest/source/conditional-simplify.d.ts +32 -0
- package/node_modules/type-fest/source/delimiter-case.d.ts +78 -0
- package/node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts +106 -0
- package/node_modules/type-fest/source/delimiter-cased-properties.d.ts +46 -0
- package/node_modules/type-fest/source/distributed-omit.d.ts +89 -0
- package/node_modules/type-fest/source/distributed-pick.d.ts +85 -0
- package/node_modules/type-fest/source/empty-object.d.ts +46 -0
- package/node_modules/type-fest/source/enforce-optional.d.ts +47 -0
- package/node_modules/type-fest/source/entries.d.ts +62 -0
- package/node_modules/type-fest/source/entry.d.ts +65 -0
- package/node_modules/type-fest/source/exact.d.ts +68 -0
- package/node_modules/type-fest/source/except.d.ts +108 -0
- package/node_modules/type-fest/source/find-global-type.d.ts +64 -0
- package/node_modules/type-fest/source/fixed-length-array.d.ts +43 -0
- package/node_modules/type-fest/source/get.d.ts +219 -0
- package/node_modules/type-fest/source/global-this.d.ts +21 -0
- package/node_modules/type-fest/source/greater-than-or-equal.d.ts +22 -0
- package/node_modules/type-fest/source/greater-than.d.ts +56 -0
- package/node_modules/type-fest/source/has-optional-keys.d.ts +21 -0
- package/node_modules/type-fest/source/has-readonly-keys.d.ts +21 -0
- package/node_modules/type-fest/source/has-required-keys.d.ts +59 -0
- package/node_modules/type-fest/source/has-writable-keys.d.ts +21 -0
- package/node_modules/type-fest/source/if-any.d.ts +24 -0
- package/node_modules/type-fest/source/if-empty-object.d.ts +26 -0
- package/node_modules/type-fest/source/if-never.d.ts +24 -0
- package/node_modules/type-fest/source/if-null.d.ts +24 -0
- package/node_modules/type-fest/source/if-unknown.d.ts +24 -0
- package/node_modules/type-fest/source/includes.d.ts +22 -0
- package/node_modules/type-fest/source/int-closed-range.d.ts +35 -0
- package/node_modules/type-fest/source/int-range.d.ts +55 -0
- package/node_modules/type-fest/source/internal/array.d.ts +126 -0
- package/node_modules/type-fest/source/internal/characters.d.ts +67 -0
- package/node_modules/type-fest/source/internal/index.d.ts +8 -0
- package/node_modules/type-fest/source/internal/keys.d.ts +97 -0
- package/node_modules/type-fest/source/internal/numeric.d.ts +118 -0
- package/node_modules/type-fest/source/internal/object.d.ts +236 -0
- package/node_modules/type-fest/source/internal/string.d.ts +210 -0
- package/node_modules/type-fest/source/internal/tuple.d.ts +90 -0
- package/node_modules/type-fest/source/internal/type.d.ts +139 -0
- package/node_modules/type-fest/source/invariant-of.d.ts +76 -0
- package/node_modules/type-fest/source/is-any.d.ts +33 -0
- package/node_modules/type-fest/source/is-equal.d.ts +31 -0
- package/node_modules/type-fest/source/is-float.d.ts +41 -0
- package/node_modules/type-fest/source/is-integer.d.ts +58 -0
- package/node_modules/type-fest/source/is-literal.d.ts +296 -0
- package/node_modules/type-fest/source/is-never.d.ts +42 -0
- package/node_modules/type-fest/source/is-null.d.ts +20 -0
- package/node_modules/type-fest/source/is-tuple.d.ts +89 -0
- package/node_modules/type-fest/source/is-unknown.d.ts +52 -0
- package/node_modules/type-fest/source/iterable-element.d.ts +64 -0
- package/node_modules/type-fest/source/join.d.ts +68 -0
- package/node_modules/type-fest/source/jsonifiable.d.ts +37 -0
- package/node_modules/type-fest/source/jsonify.d.ts +122 -0
- package/node_modules/type-fest/source/kebab-case.d.ts +44 -0
- package/node_modules/type-fest/source/kebab-cased-properties-deep.d.ts +63 -0
- package/node_modules/type-fest/source/kebab-cased-properties.d.ts +40 -0
- package/node_modules/type-fest/source/keys-of-union.d.ts +42 -0
- package/node_modules/type-fest/source/last-array-element.d.ts +38 -0
- package/node_modules/type-fest/source/less-than-or-equal.d.ts +22 -0
- package/node_modules/type-fest/source/less-than.d.ts +26 -0
- package/node_modules/type-fest/source/literal-to-primitive-deep.d.ts +36 -0
- package/node_modules/type-fest/source/literal-to-primitive.d.ts +36 -0
- package/node_modules/type-fest/source/literal-union.d.ts +37 -0
- package/node_modules/type-fest/source/merge-deep.d.ts +486 -0
- package/node_modules/type-fest/source/merge-exclusive.d.ts +41 -0
- package/node_modules/type-fest/source/merge.d.ts +48 -0
- package/node_modules/type-fest/source/multidimensional-array.d.ts +44 -0
- package/node_modules/type-fest/source/multidimensional-readonly-array.d.ts +48 -0
- package/node_modules/type-fest/source/non-empty-object.d.ts +35 -0
- package/node_modules/type-fest/source/non-empty-string.d.ts +28 -0
- package/node_modules/type-fest/source/non-empty-tuple.d.ts +21 -0
- package/node_modules/type-fest/source/numeric.d.ts +222 -0
- package/node_modules/type-fest/source/observable-like.d.ts +63 -0
- package/node_modules/type-fest/source/omit-deep.d.ts +167 -0
- package/node_modules/type-fest/source/omit-index-signature.d.ts +95 -0
- package/node_modules/type-fest/source/opaque.d.ts +1 -0
- package/node_modules/type-fest/source/optional-keys-of.d.ts +39 -0
- package/node_modules/type-fest/source/or.d.ts +25 -0
- package/node_modules/type-fest/source/override-properties.d.ts +36 -0
- package/node_modules/type-fest/source/package-json.d.ts +676 -0
- package/node_modules/type-fest/source/partial-deep.d.ts +151 -0
- package/node_modules/type-fest/source/partial-on-undefined-deep.d.ts +78 -0
- package/node_modules/type-fest/source/pascal-case.d.ts +42 -0
- package/node_modules/type-fest/source/pascal-cased-properties-deep.d.ts +62 -0
- package/node_modules/type-fest/source/pascal-cased-properties.d.ts +36 -0
- package/node_modules/type-fest/source/paths.d.ts +262 -0
- package/node_modules/type-fest/source/pick-deep.d.ts +149 -0
- package/node_modules/type-fest/source/pick-index-signature.d.ts +50 -0
- package/node_modules/type-fest/source/primitive.d.ts +13 -0
- package/node_modules/type-fest/source/promisable.d.ts +25 -0
- package/node_modules/type-fest/source/readonly-deep.d.ts +81 -0
- package/node_modules/type-fest/source/readonly-keys-of.d.ts +30 -0
- package/node_modules/type-fest/source/readonly-tuple.d.ts +41 -0
- package/node_modules/type-fest/source/replace.d.ts +85 -0
- package/node_modules/type-fest/source/require-all-or-none.d.ts +51 -0
- package/node_modules/type-fest/source/require-at-least-one.d.ts +47 -0
- package/node_modules/type-fest/source/require-exactly-one.d.ts +45 -0
- package/node_modules/type-fest/source/require-one-or-none.d.ts +46 -0
- package/node_modules/type-fest/source/required-deep.d.ts +78 -0
- package/node_modules/type-fest/source/required-keys-of.d.ts +30 -0
- package/node_modules/type-fest/source/schema.d.ts +114 -0
- package/node_modules/type-fest/source/screaming-snake-case.d.ts +28 -0
- package/node_modules/type-fest/source/set-field-type.d.ts +65 -0
- package/node_modules/type-fest/source/set-non-nullable-deep.d.ts +83 -0
- package/node_modules/type-fest/source/set-non-nullable.d.ts +39 -0
- package/node_modules/type-fest/source/set-optional.d.ts +38 -0
- package/node_modules/type-fest/source/set-parameter-type.d.ts +117 -0
- package/node_modules/type-fest/source/set-readonly.d.ts +39 -0
- package/node_modules/type-fest/source/set-required-deep.d.ts +68 -0
- package/node_modules/type-fest/source/set-required.d.ts +70 -0
- package/node_modules/type-fest/source/set-return-type.d.ts +29 -0
- package/node_modules/type-fest/source/shared-union-fields-deep.d.ts +178 -0
- package/node_modules/type-fest/source/shared-union-fields.d.ts +76 -0
- package/node_modules/type-fest/source/simplify-deep.d.ts +115 -0
- package/node_modules/type-fest/source/simplify.d.ts +58 -0
- package/node_modules/type-fest/source/single-key-object.d.ts +29 -0
- package/node_modules/type-fest/source/snake-case.d.ts +45 -0
- package/node_modules/type-fest/source/snake-cased-properties-deep.d.ts +63 -0
- package/node_modules/type-fest/source/snake-cased-properties.d.ts +40 -0
- package/node_modules/type-fest/source/split.d.ts +88 -0
- package/node_modules/type-fest/source/spread.d.ts +84 -0
- package/node_modules/type-fest/source/string-key-of.d.ts +25 -0
- package/node_modules/type-fest/source/string-repeat.d.ts +47 -0
- package/node_modules/type-fest/source/string-slice.d.ts +37 -0
- package/node_modules/type-fest/source/stringified.d.ts +23 -0
- package/node_modules/type-fest/source/structured-cloneable.d.ts +92 -0
- package/node_modules/type-fest/source/subtract.d.ts +83 -0
- package/node_modules/type-fest/source/sum.d.ts +78 -0
- package/node_modules/type-fest/source/tagged-union.d.ts +51 -0
- package/node_modules/type-fest/source/tagged.d.ts +256 -0
- package/node_modules/type-fest/source/trim.d.ts +27 -0
- package/node_modules/type-fest/source/tsconfig-json.d.ts +1294 -0
- package/node_modules/type-fest/source/tuple-to-object.d.ts +42 -0
- package/node_modules/type-fest/source/tuple-to-union.d.ts +51 -0
- package/node_modules/type-fest/source/typed-array.d.ts +17 -0
- package/node_modules/type-fest/source/undefined-on-partial-deep.d.ts +80 -0
- package/node_modules/type-fest/source/union-to-intersection.d.ts +61 -0
- package/node_modules/type-fest/source/union-to-tuple.d.ts +56 -0
- package/node_modules/type-fest/source/unknown-array.d.ts +25 -0
- package/node_modules/type-fest/source/unknown-map.d.ts +24 -0
- package/node_modules/type-fest/source/unknown-record.d.ts +31 -0
- package/node_modules/type-fest/source/unknown-set.d.ts +24 -0
- package/node_modules/type-fest/source/value-of.d.ts +42 -0
- package/node_modules/type-fest/source/words.d.ts +118 -0
- package/node_modules/type-fest/source/writable-deep.d.ts +83 -0
- package/node_modules/type-fest/source/writable-keys-of.d.ts +33 -0
- package/node_modules/type-fest/source/writable.d.ts +68 -0
- package/node_modules/widest-line/index.d.ts +12 -0
- package/node_modules/widest-line/index.js +11 -0
- package/node_modules/widest-line/license +9 -0
- package/node_modules/widest-line/package.json +60 -0
- package/node_modules/widest-line/readme.md +26 -0
- package/node_modules/wrap-ansi/index.d.ts +41 -0
- package/node_modules/wrap-ansi/index.js +222 -0
- package/node_modules/wrap-ansi/license +9 -0
- package/node_modules/wrap-ansi/package.json +69 -0
- package/node_modules/wrap-ansi/readme.md +75 -0
- package/package.json +78 -0
- package/scripts/postinstall.cjs +122 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type {CamelCase, CamelCaseOptions, DefaultCamelCaseOptions} from './camel-case';
|
|
2
|
+
import type {ApplyDefaultOptions, NonRecursiveType} from './internal';
|
|
3
|
+
import type {UnknownArray} from './unknown-array';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
Convert object properties to camel case recursively.
|
|
7
|
+
|
|
8
|
+
This can be useful when, for example, converting some API types from a different style.
|
|
9
|
+
|
|
10
|
+
@see CamelCasedProperties
|
|
11
|
+
@see CamelCase
|
|
12
|
+
|
|
13
|
+
@example
|
|
14
|
+
```
|
|
15
|
+
import type {CamelCasedPropertiesDeep} from 'type-fest';
|
|
16
|
+
|
|
17
|
+
interface User {
|
|
18
|
+
UserId: number;
|
|
19
|
+
UserName: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface UserWithFriends {
|
|
23
|
+
UserInfo: User;
|
|
24
|
+
UserFriends: User[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const result: CamelCasedPropertiesDeep<UserWithFriends> = {
|
|
28
|
+
userInfo: {
|
|
29
|
+
userId: 1,
|
|
30
|
+
userName: 'Tom',
|
|
31
|
+
},
|
|
32
|
+
userFriends: [
|
|
33
|
+
{
|
|
34
|
+
userId: 2,
|
|
35
|
+
userName: 'Jerry',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
userId: 3,
|
|
39
|
+
userName: 'Spike',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const preserveConsecutiveUppercase: CamelCasedPropertiesDeep<{fooBAR: { fooBARBiz: [{ fooBARBaz: string }] }}, {preserveConsecutiveUppercase: false}> = {
|
|
45
|
+
fooBar: {
|
|
46
|
+
fooBarBiz: [{
|
|
47
|
+
fooBarBaz: 'string',
|
|
48
|
+
}],
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
@category Change case
|
|
54
|
+
@category Template literal
|
|
55
|
+
@category Object
|
|
56
|
+
*/
|
|
57
|
+
export type CamelCasedPropertiesDeep<
|
|
58
|
+
Value,
|
|
59
|
+
Options extends CamelCaseOptions = {},
|
|
60
|
+
> = _CamelCasedPropertiesDeep<Value, ApplyDefaultOptions<CamelCaseOptions, DefaultCamelCaseOptions, Options>>;
|
|
61
|
+
|
|
62
|
+
type _CamelCasedPropertiesDeep<
|
|
63
|
+
Value,
|
|
64
|
+
Options extends Required<CamelCaseOptions>,
|
|
65
|
+
> = Value extends NonRecursiveType
|
|
66
|
+
? Value
|
|
67
|
+
: Value extends UnknownArray
|
|
68
|
+
? CamelCasedPropertiesArrayDeep<Value, Options>
|
|
69
|
+
: Value extends Set<infer U>
|
|
70
|
+
? Set<_CamelCasedPropertiesDeep<U, Options>>
|
|
71
|
+
: Value extends object
|
|
72
|
+
? {
|
|
73
|
+
[K in keyof Value as CamelCase<K, Options>]: _CamelCasedPropertiesDeep<Value[K], Options>;
|
|
74
|
+
}
|
|
75
|
+
: Value;
|
|
76
|
+
|
|
77
|
+
// This is a copy of DelimiterCasedPropertiesArrayDeep (see: delimiter-cased-properties-deep.d.ts).
|
|
78
|
+
// These types should be kept in sync.
|
|
79
|
+
type CamelCasedPropertiesArrayDeep<
|
|
80
|
+
Value extends UnknownArray,
|
|
81
|
+
Options extends Required<CamelCaseOptions>,
|
|
82
|
+
> = Value extends []
|
|
83
|
+
? []
|
|
84
|
+
// Trailing spread array
|
|
85
|
+
: Value extends [infer U, ...infer V]
|
|
86
|
+
? [_CamelCasedPropertiesDeep<U, Options>, ..._CamelCasedPropertiesDeep<V, Options>]
|
|
87
|
+
: Value extends readonly [infer U, ...infer V]
|
|
88
|
+
? readonly [_CamelCasedPropertiesDeep<U, Options>, ..._CamelCasedPropertiesDeep<V, Options>]
|
|
89
|
+
: // Leading spread array
|
|
90
|
+
Value extends readonly [...infer U, infer V]
|
|
91
|
+
? [..._CamelCasedPropertiesDeep<U, Options>, _CamelCasedPropertiesDeep<V, Options>]
|
|
92
|
+
: // Array
|
|
93
|
+
Value extends Array<infer U>
|
|
94
|
+
? Array<_CamelCasedPropertiesDeep<U, Options>>
|
|
95
|
+
: Value extends ReadonlyArray<infer U>
|
|
96
|
+
? ReadonlyArray<_CamelCasedPropertiesDeep<U, Options>>
|
|
97
|
+
: never;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type {CamelCase, CamelCaseOptions, DefaultCamelCaseOptions} from './camel-case';
|
|
2
|
+
import type {ApplyDefaultOptions} from './internal';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
Convert object properties to camel case but not recursively.
|
|
6
|
+
|
|
7
|
+
This can be useful when, for example, converting some API types from a different style.
|
|
8
|
+
|
|
9
|
+
@see CamelCasedPropertiesDeep
|
|
10
|
+
@see CamelCase
|
|
11
|
+
|
|
12
|
+
@example
|
|
13
|
+
```
|
|
14
|
+
import type {CamelCasedProperties} from 'type-fest';
|
|
15
|
+
|
|
16
|
+
interface User {
|
|
17
|
+
UserId: number;
|
|
18
|
+
UserName: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const result: CamelCasedProperties<User> = {
|
|
22
|
+
userId: 1,
|
|
23
|
+
userName: 'Tom',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const preserveConsecutiveUppercase: CamelCasedProperties<{fooBAR: string}, {preserveConsecutiveUppercase: false}> = {
|
|
27
|
+
fooBar: 'string',
|
|
28
|
+
};
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
@category Change case
|
|
32
|
+
@category Template literal
|
|
33
|
+
@category Object
|
|
34
|
+
*/
|
|
35
|
+
export type CamelCasedProperties<Value, Options extends CamelCaseOptions = {}> = Value extends Function
|
|
36
|
+
? Value
|
|
37
|
+
: Value extends Array<infer U>
|
|
38
|
+
? Value
|
|
39
|
+
: {
|
|
40
|
+
[K in keyof Value as
|
|
41
|
+
CamelCase<K, ApplyDefaultOptions<CamelCaseOptions, DefaultCamelCaseOptions, Options>>
|
|
42
|
+
]: Value[K];
|
|
43
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type {Except} from './except';
|
|
2
|
+
import type {ConditionalKeys} from './conditional-keys';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
Exclude keys from a shape that matches the given `Condition`.
|
|
6
|
+
|
|
7
|
+
This is useful when you want to create a new type with a specific set of keys from a shape. For example, you might want to exclude all the primitive properties from a class and form a new shape containing everything but the primitive properties.
|
|
8
|
+
|
|
9
|
+
@example
|
|
10
|
+
```
|
|
11
|
+
import type {Primitive, ConditionalExcept} from 'type-fest';
|
|
12
|
+
|
|
13
|
+
class Awesome {
|
|
14
|
+
name: string;
|
|
15
|
+
successes: number;
|
|
16
|
+
failures: bigint;
|
|
17
|
+
|
|
18
|
+
run() {}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type ExceptPrimitivesFromAwesome = ConditionalExcept<Awesome, Primitive>;
|
|
22
|
+
//=> {run: () => void}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
@example
|
|
26
|
+
```
|
|
27
|
+
import type {ConditionalExcept} from 'type-fest';
|
|
28
|
+
|
|
29
|
+
interface Example {
|
|
30
|
+
a: string;
|
|
31
|
+
b: string | number;
|
|
32
|
+
c: () => void;
|
|
33
|
+
d: {};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type NonStringKeysOnly = ConditionalExcept<Example, string>;
|
|
37
|
+
//=> {b: string | number; c: () => void; d: {}}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
@category Object
|
|
41
|
+
*/
|
|
42
|
+
export type ConditionalExcept<Base, Condition> = Except<
|
|
43
|
+
Base,
|
|
44
|
+
ConditionalKeys<Base, Condition>
|
|
45
|
+
>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type {IfNever} from './if-never';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
Extract the keys from a type where the value type of the key extends the given `Condition`.
|
|
5
|
+
|
|
6
|
+
Internally this is used for the `ConditionalPick` and `ConditionalExcept` types.
|
|
7
|
+
|
|
8
|
+
@example
|
|
9
|
+
```
|
|
10
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
11
|
+
|
|
12
|
+
interface Example {
|
|
13
|
+
a: string;
|
|
14
|
+
b: string | number;
|
|
15
|
+
c?: string;
|
|
16
|
+
d: {};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type StringKeysOnly = ConditionalKeys<Example, string>;
|
|
20
|
+
//=> 'a'
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
To support partial types, make sure your `Condition` is a union of undefined (for example, `string | undefined`) as demonstrated below.
|
|
24
|
+
|
|
25
|
+
@example
|
|
26
|
+
```
|
|
27
|
+
import type {ConditionalKeys} from 'type-fest';
|
|
28
|
+
|
|
29
|
+
type StringKeysAndUndefined = ConditionalKeys<Example, string | undefined>;
|
|
30
|
+
//=> 'a' | 'c'
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
@category Object
|
|
34
|
+
*/
|
|
35
|
+
export type ConditionalKeys<Base, Condition> =
|
|
36
|
+
{
|
|
37
|
+
// Map through all the keys of the given base type.
|
|
38
|
+
[Key in keyof Base]-?:
|
|
39
|
+
// Pick only keys with types extending the given `Condition` type.
|
|
40
|
+
Base[Key] extends Condition
|
|
41
|
+
// Retain this key
|
|
42
|
+
// If the value for the key extends never, only include it if `Condition` also extends never
|
|
43
|
+
? IfNever<Base[Key], IfNever<Condition, Key, never>, Key>
|
|
44
|
+
// Discard this key since the condition fails.
|
|
45
|
+
: never;
|
|
46
|
+
// Convert the produced object into a union type of the keys which passed the conditional test.
|
|
47
|
+
}[keyof Base];
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type {IsEqual} from './is-equal';
|
|
2
|
+
import type {ConditionalExcept} from './conditional-except';
|
|
3
|
+
import type {ConditionalSimplifyDeep} from './conditional-simplify';
|
|
4
|
+
import type {UnknownRecord} from './unknown-record';
|
|
5
|
+
import type {EmptyObject} from './empty-object';
|
|
6
|
+
import type {ApplyDefaultOptions, IsPlainObject} from './internal';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
Used to mark properties that should be excluded.
|
|
10
|
+
*/
|
|
11
|
+
declare const conditionalPickDeepSymbol: unique symbol;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
Assert the condition according to the {@link ConditionalPickDeepOptions.condition|condition} option.
|
|
15
|
+
*/
|
|
16
|
+
type AssertCondition<Type, Condition, Options extends ConditionalPickDeepOptions> = Options['condition'] extends 'equality'
|
|
17
|
+
? IsEqual<Type, Condition>
|
|
18
|
+
: Type extends Condition
|
|
19
|
+
? true
|
|
20
|
+
: false;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
ConditionalPickDeep options.
|
|
24
|
+
|
|
25
|
+
@see ConditionalPickDeep
|
|
26
|
+
*/
|
|
27
|
+
export type ConditionalPickDeepOptions = {
|
|
28
|
+
/**
|
|
29
|
+
The condition assertion mode.
|
|
30
|
+
|
|
31
|
+
@default 'extends'
|
|
32
|
+
*/
|
|
33
|
+
condition?: 'extends' | 'equality';
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type DefaultConditionalPickDeepOptions = {
|
|
37
|
+
condition: 'extends';
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
Pick keys recursively from the shape that matches the given condition.
|
|
42
|
+
|
|
43
|
+
@see ConditionalPick
|
|
44
|
+
|
|
45
|
+
@example
|
|
46
|
+
```
|
|
47
|
+
import type {ConditionalPickDeep} from 'type-fest';
|
|
48
|
+
|
|
49
|
+
interface Example {
|
|
50
|
+
a: string;
|
|
51
|
+
b: string | boolean;
|
|
52
|
+
c: {
|
|
53
|
+
d: string;
|
|
54
|
+
e: {
|
|
55
|
+
f?: string;
|
|
56
|
+
g?: boolean;
|
|
57
|
+
h: string | boolean;
|
|
58
|
+
i: boolean | bigint;
|
|
59
|
+
};
|
|
60
|
+
j: boolean;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type StringPick = ConditionalPickDeep<Example, string>;
|
|
65
|
+
//=> {a: string; c: {d: string}}
|
|
66
|
+
|
|
67
|
+
type StringPickOptional = ConditionalPickDeep<Example, string | undefined>;
|
|
68
|
+
//=> {a: string; c: {d: string; e: {f?: string}}}
|
|
69
|
+
|
|
70
|
+
type StringPickOptionalOnly = ConditionalPickDeep<Example, string | undefined, {condition: 'equality'}>;
|
|
71
|
+
//=> {c: {e: {f?: string}}}
|
|
72
|
+
|
|
73
|
+
type BooleanPick = ConditionalPickDeep<Example, boolean | undefined>;
|
|
74
|
+
//=> {c: {e: {g?: boolean}; j: boolean}}
|
|
75
|
+
|
|
76
|
+
type NumberPick = ConditionalPickDeep<Example, number>;
|
|
77
|
+
//=> {}
|
|
78
|
+
|
|
79
|
+
type StringOrBooleanPick = ConditionalPickDeep<Example, string | boolean>;
|
|
80
|
+
//=> {
|
|
81
|
+
// a: string;
|
|
82
|
+
// b: string | boolean;
|
|
83
|
+
// c: {
|
|
84
|
+
// d: string;
|
|
85
|
+
// e: {
|
|
86
|
+
// h: string | boolean
|
|
87
|
+
// };
|
|
88
|
+
// j: boolean;
|
|
89
|
+
// };
|
|
90
|
+
// }
|
|
91
|
+
|
|
92
|
+
type StringOrBooleanPickOnly = ConditionalPickDeep<Example, string | boolean, {condition: 'equality'}>;
|
|
93
|
+
//=> {b: string | boolean; c: {e: {h: string | boolean}}}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
@category Object
|
|
97
|
+
*/
|
|
98
|
+
export type ConditionalPickDeep<
|
|
99
|
+
Type,
|
|
100
|
+
Condition,
|
|
101
|
+
Options extends ConditionalPickDeepOptions = {},
|
|
102
|
+
> = _ConditionalPickDeep<
|
|
103
|
+
Type,
|
|
104
|
+
Condition,
|
|
105
|
+
ApplyDefaultOptions<ConditionalPickDeepOptions, DefaultConditionalPickDeepOptions, Options>
|
|
106
|
+
>;
|
|
107
|
+
|
|
108
|
+
type _ConditionalPickDeep<
|
|
109
|
+
Type,
|
|
110
|
+
Condition,
|
|
111
|
+
Options extends Required<ConditionalPickDeepOptions>,
|
|
112
|
+
> = ConditionalSimplifyDeep<ConditionalExcept<{
|
|
113
|
+
[Key in keyof Type]: AssertCondition<Type[Key], Condition, Options> extends true
|
|
114
|
+
? Type[Key]
|
|
115
|
+
: IsPlainObject<Type[Key]> extends true
|
|
116
|
+
? _ConditionalPickDeep<Type[Key], Condition, Options>
|
|
117
|
+
: typeof conditionalPickDeepSymbol;
|
|
118
|
+
}, (typeof conditionalPickDeepSymbol | undefined) | EmptyObject>, never, UnknownRecord>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type {ConditionalKeys} from './conditional-keys';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
Pick keys from the shape that matches the given `Condition`.
|
|
5
|
+
|
|
6
|
+
This is useful when you want to create a new type from a specific subset of an existing type. For example, you might want to pick all the primitive properties from a class and form a new automatically derived type.
|
|
7
|
+
|
|
8
|
+
@example
|
|
9
|
+
```
|
|
10
|
+
import type {Primitive, ConditionalPick} from 'type-fest';
|
|
11
|
+
|
|
12
|
+
class Awesome {
|
|
13
|
+
name: string;
|
|
14
|
+
successes: number;
|
|
15
|
+
failures: bigint;
|
|
16
|
+
|
|
17
|
+
run() {}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type PickPrimitivesFromAwesome = ConditionalPick<Awesome, Primitive>;
|
|
21
|
+
//=> {name: string; successes: number; failures: bigint}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
@example
|
|
25
|
+
```
|
|
26
|
+
import type {ConditionalPick} from 'type-fest';
|
|
27
|
+
|
|
28
|
+
interface Example {
|
|
29
|
+
a: string;
|
|
30
|
+
b: string | number;
|
|
31
|
+
c: () => void;
|
|
32
|
+
d: {};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
type StringKeysOnly = ConditionalPick<Example, string>;
|
|
36
|
+
//=> {a: string}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
@category Object
|
|
40
|
+
*/
|
|
41
|
+
export type ConditionalPick<Base, Condition> = Pick<
|
|
42
|
+
Base,
|
|
43
|
+
ConditionalKeys<Base, Condition>
|
|
44
|
+
>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Simplifies a type while including and/or excluding certain types from being simplified. Useful to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
3
|
+
|
|
4
|
+
This type is **experimental** and was introduced as a result of this {@link https://github.com/sindresorhus/type-fest/issues/436 issue}. It should be used with caution.
|
|
5
|
+
|
|
6
|
+
@internal
|
|
7
|
+
@experimental
|
|
8
|
+
@see Simplify
|
|
9
|
+
@category Object
|
|
10
|
+
*/
|
|
11
|
+
export type ConditionalSimplify<Type, ExcludeType = never, IncludeType = unknown> = Type extends ExcludeType
|
|
12
|
+
? Type
|
|
13
|
+
: Type extends IncludeType
|
|
14
|
+
? {[TypeKey in keyof Type]: Type[TypeKey]}
|
|
15
|
+
: Type;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
Recursively simplifies a type while including and/or excluding certain types from being simplified.
|
|
19
|
+
|
|
20
|
+
This type is **experimental** and was introduced as a result of this {@link https://github.com/sindresorhus/type-fest/issues/436 issue}. It should be used with caution.
|
|
21
|
+
|
|
22
|
+
See {@link ConditionalSimplify} for usages and examples.
|
|
23
|
+
|
|
24
|
+
@internal
|
|
25
|
+
@experimental
|
|
26
|
+
@category Object
|
|
27
|
+
*/
|
|
28
|
+
export type ConditionalSimplifyDeep<Type, ExcludeType = never, IncludeType = unknown> = Type extends ExcludeType
|
|
29
|
+
? Type
|
|
30
|
+
: Type extends IncludeType
|
|
31
|
+
? {[TypeKey in keyof Type]: ConditionalSimplifyDeep<Type[TypeKey], ExcludeType, IncludeType>}
|
|
32
|
+
: Type;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type {ApplyDefaultOptions, AsciiPunctuation, StartsWith} from './internal';
|
|
2
|
+
import type {IsStringLiteral} from './is-literal';
|
|
3
|
+
import type {Merge} from './merge';
|
|
4
|
+
import type {DefaultWordsOptions, Words, WordsOptions} from './words';
|
|
5
|
+
|
|
6
|
+
export type DefaultDelimiterCaseOptions = Merge<DefaultWordsOptions, {splitOnNumbers: false}>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
Convert an array of words to delimiter case starting with a delimiter with input capitalization.
|
|
10
|
+
*/
|
|
11
|
+
type DelimiterCaseFromArray<
|
|
12
|
+
Words extends string[],
|
|
13
|
+
Delimiter extends string,
|
|
14
|
+
OutputString extends string = '',
|
|
15
|
+
> = Words extends [
|
|
16
|
+
infer FirstWord extends string,
|
|
17
|
+
...infer RemainingWords extends string[],
|
|
18
|
+
]
|
|
19
|
+
? DelimiterCaseFromArray<RemainingWords, Delimiter, `${OutputString}${
|
|
20
|
+
StartsWith<FirstWord, AsciiPunctuation> extends true ? '' : Delimiter
|
|
21
|
+
}${FirstWord}`>
|
|
22
|
+
: OutputString;
|
|
23
|
+
|
|
24
|
+
type RemoveFirstLetter<S extends string> = S extends `${infer _}${infer Rest}`
|
|
25
|
+
? Rest
|
|
26
|
+
: '';
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
Convert a string literal to a custom string delimiter casing.
|
|
30
|
+
|
|
31
|
+
This can be useful when, for example, converting a camel-cased object property to an oddly cased one.
|
|
32
|
+
|
|
33
|
+
@see KebabCase
|
|
34
|
+
@see SnakeCase
|
|
35
|
+
|
|
36
|
+
@example
|
|
37
|
+
```
|
|
38
|
+
import type {DelimiterCase} from 'type-fest';
|
|
39
|
+
|
|
40
|
+
// Simple
|
|
41
|
+
|
|
42
|
+
const someVariable: DelimiterCase<'fooBar', '#'> = 'foo#bar';
|
|
43
|
+
const someVariableNoSplitOnNumbers: DelimiterCase<'p2pNetwork', '#', {splitOnNumbers: false}> = 'p2p#network';
|
|
44
|
+
|
|
45
|
+
// Advanced
|
|
46
|
+
|
|
47
|
+
type OddlyCasedProperties<T> = {
|
|
48
|
+
[K in keyof T as DelimiterCase<K, '#'>]: T[K]
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
interface SomeOptions {
|
|
52
|
+
dryRun: boolean;
|
|
53
|
+
includeFile: string;
|
|
54
|
+
foo: number;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const rawCliOptions: OddlyCasedProperties<SomeOptions> = {
|
|
58
|
+
'dry#run': true,
|
|
59
|
+
'include#file': 'bar.js',
|
|
60
|
+
foo: 123
|
|
61
|
+
};
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
@category Change case
|
|
65
|
+
@category Template literal
|
|
66
|
+
*/
|
|
67
|
+
export type DelimiterCase<
|
|
68
|
+
Value,
|
|
69
|
+
Delimiter extends string,
|
|
70
|
+
Options extends WordsOptions = {},
|
|
71
|
+
> = Value extends string
|
|
72
|
+
? IsStringLiteral<Value> extends false
|
|
73
|
+
? Value
|
|
74
|
+
: Lowercase<RemoveFirstLetter<DelimiterCaseFromArray<
|
|
75
|
+
Words<Value, ApplyDefaultOptions<WordsOptions, DefaultDelimiterCaseOptions, Options>>,
|
|
76
|
+
Delimiter
|
|
77
|
+
>>>
|
|
78
|
+
: Value;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type {DefaultDelimiterCaseOptions, DelimiterCase} from './delimiter-case';
|
|
2
|
+
import type {ApplyDefaultOptions, NonRecursiveType} from './internal';
|
|
3
|
+
import type {UnknownArray} from './unknown-array';
|
|
4
|
+
import type {WordsOptions} from './words';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
Convert object properties to delimiter case recursively.
|
|
8
|
+
|
|
9
|
+
This can be useful when, for example, converting some API types from a different style.
|
|
10
|
+
|
|
11
|
+
@see DelimiterCase
|
|
12
|
+
@see DelimiterCasedProperties
|
|
13
|
+
|
|
14
|
+
@example
|
|
15
|
+
```
|
|
16
|
+
import type {DelimiterCasedPropertiesDeep} from 'type-fest';
|
|
17
|
+
|
|
18
|
+
interface User {
|
|
19
|
+
userId: number;
|
|
20
|
+
userName: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface UserWithFriends {
|
|
24
|
+
userInfo: User;
|
|
25
|
+
userFriends: User[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const result: DelimiterCasedPropertiesDeep<UserWithFriends, '-'> = {
|
|
29
|
+
'user-info': {
|
|
30
|
+
'user-id': 1,
|
|
31
|
+
'user-name': 'Tom',
|
|
32
|
+
},
|
|
33
|
+
'user-friends': [
|
|
34
|
+
{
|
|
35
|
+
'user-id': 2,
|
|
36
|
+
'user-name': 'Jerry',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
'user-id': 3,
|
|
40
|
+
'user-name': 'Spike',
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const splitOnNumbers: DelimiterCasedPropertiesDeep<{line1: { line2: [{ line3: string }] }}, '-', {splitOnNumbers: true}> = {
|
|
46
|
+
'line-1': {
|
|
47
|
+
'line-2': [
|
|
48
|
+
{
|
|
49
|
+
'line-3': 'string',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
@category Change case
|
|
57
|
+
@category Template literal
|
|
58
|
+
@category Object
|
|
59
|
+
*/
|
|
60
|
+
export type DelimiterCasedPropertiesDeep<
|
|
61
|
+
Value,
|
|
62
|
+
Delimiter extends string,
|
|
63
|
+
Options extends WordsOptions = {},
|
|
64
|
+
> = _DelimiterCasedPropertiesDeep<Value, Delimiter, ApplyDefaultOptions<WordsOptions, DefaultDelimiterCaseOptions, Options>>;
|
|
65
|
+
|
|
66
|
+
type _DelimiterCasedPropertiesDeep<
|
|
67
|
+
Value,
|
|
68
|
+
Delimiter extends string,
|
|
69
|
+
Options extends Required<WordsOptions>,
|
|
70
|
+
> = Value extends NonRecursiveType
|
|
71
|
+
? Value
|
|
72
|
+
: Value extends UnknownArray
|
|
73
|
+
? DelimiterCasedPropertiesArrayDeep<Value, Delimiter, Options>
|
|
74
|
+
: Value extends Set<infer U>
|
|
75
|
+
? Set<_DelimiterCasedPropertiesDeep<U, Delimiter, Options>>
|
|
76
|
+
: Value extends object
|
|
77
|
+
? {
|
|
78
|
+
[K in keyof Value as DelimiterCase<K, Delimiter, Options>]:
|
|
79
|
+
_DelimiterCasedPropertiesDeep<Value[K], Delimiter, Options>
|
|
80
|
+
}
|
|
81
|
+
: Value;
|
|
82
|
+
|
|
83
|
+
// This is a copy of CamelCasedPropertiesArrayDeep (see: camel-cased-properties-deep.d.ts).
|
|
84
|
+
// These types should be kept in sync.
|
|
85
|
+
type DelimiterCasedPropertiesArrayDeep<
|
|
86
|
+
Value extends UnknownArray,
|
|
87
|
+
Delimiter extends string,
|
|
88
|
+
Options extends Required<WordsOptions>,
|
|
89
|
+
> = Value extends []
|
|
90
|
+
? []
|
|
91
|
+
// Trailing spread array
|
|
92
|
+
: Value extends [infer U, ...infer V]
|
|
93
|
+
? [_DelimiterCasedPropertiesDeep<U, Delimiter, Options>, ..._DelimiterCasedPropertiesDeep<V, Delimiter, Options>]
|
|
94
|
+
: Value extends readonly [infer U, ...infer V]
|
|
95
|
+
? readonly [_DelimiterCasedPropertiesDeep<U, Delimiter, Options>, ..._DelimiterCasedPropertiesDeep<V, Delimiter, Options>]
|
|
96
|
+
// Leading spread array
|
|
97
|
+
: Value extends [...infer U, infer V]
|
|
98
|
+
? [..._DelimiterCasedPropertiesDeep<U, Delimiter, Options>, _DelimiterCasedPropertiesDeep<V, Delimiter, Options>]
|
|
99
|
+
: Value extends readonly [...infer U, infer V]
|
|
100
|
+
? readonly [..._DelimiterCasedPropertiesDeep<U, Delimiter, Options>, _DelimiterCasedPropertiesDeep<V, Delimiter, Options>]
|
|
101
|
+
// Array
|
|
102
|
+
: Value extends Array<infer U>
|
|
103
|
+
? Array<_DelimiterCasedPropertiesDeep<U, Delimiter, Options>>
|
|
104
|
+
: Value extends ReadonlyArray<infer U>
|
|
105
|
+
? ReadonlyArray<_DelimiterCasedPropertiesDeep<U, Delimiter, Options>>
|
|
106
|
+
: never;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type {DefaultDelimiterCaseOptions, DelimiterCase} from './delimiter-case';
|
|
2
|
+
import type {ApplyDefaultOptions} from './internal';
|
|
3
|
+
import type {WordsOptions} from './words';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
Convert object properties to delimiter case but not recursively.
|
|
7
|
+
|
|
8
|
+
This can be useful when, for example, converting some API types from a different style.
|
|
9
|
+
|
|
10
|
+
@see DelimiterCase
|
|
11
|
+
@see DelimiterCasedPropertiesDeep
|
|
12
|
+
|
|
13
|
+
@example
|
|
14
|
+
```
|
|
15
|
+
import type {DelimiterCasedProperties} from 'type-fest';
|
|
16
|
+
|
|
17
|
+
interface User {
|
|
18
|
+
userId: number;
|
|
19
|
+
userName: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const result: DelimiterCasedProperties<User, '-'> = {
|
|
23
|
+
'user-id': 1,
|
|
24
|
+
'user-name': 'Tom',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const splitOnNumbers: DelimiterCasedProperties<{line1: string}, '-', {splitOnNumbers: true}> = {
|
|
28
|
+
'line-1': 'string',
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
@category Change case
|
|
33
|
+
@category Template literal
|
|
34
|
+
@category Object
|
|
35
|
+
*/
|
|
36
|
+
export type DelimiterCasedProperties<
|
|
37
|
+
Value,
|
|
38
|
+
Delimiter extends string,
|
|
39
|
+
Options extends WordsOptions = {},
|
|
40
|
+
> = Value extends Function
|
|
41
|
+
? Value
|
|
42
|
+
: Value extends Array<infer U>
|
|
43
|
+
? Value
|
|
44
|
+
: {[K in keyof Value as
|
|
45
|
+
DelimiterCase<K, Delimiter, ApplyDefaultOptions<WordsOptions, DefaultDelimiterCaseOptions, Options>>
|
|
46
|
+
]: Value[K]};
|