cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
src/internal/qs/types.ts
71lines · modecode
| 1 | export type Format = 'RFC1738' | 'RFC3986'; |
| 2 | |
| 3 | export type DefaultEncoder = (str: any, defaultEncoder?: any, charset?: string) => string; |
| 4 | export type DefaultDecoder = (str: string, decoder?: any, charset?: string) => string; |
| 5 | |
| 6 | export type BooleanOptional = boolean | undefined; |
| 7 | |
| 8 | export type StringifyBaseOptions = { |
| 9 | delimiter?: string; |
| 10 | allowDots?: boolean; |
| 11 | encodeDotInKeys?: boolean; |
| 12 | strictNullHandling?: boolean; |
| 13 | skipNulls?: boolean; |
| 14 | encode?: boolean; |
| 15 | encoder?: ( |
| 16 | str: any, |
| 17 | defaultEncoder: DefaultEncoder, |
| 18 | charset: string, |
| 19 | type: 'key' | 'value', |
| 20 | format?: Format, |
| 21 | ) => string; |
| 22 | filter?: Array<PropertyKey> | ((prefix: PropertyKey, value: any) => any); |
| 23 | arrayFormat?: 'indices' | 'brackets' | 'repeat' | 'comma'; |
| 24 | indices?: boolean; |
| 25 | sort?: ((a: PropertyKey, b: PropertyKey) => number) | null; |
| 26 | serializeDate?: (d: Date) => string; |
| 27 | format?: 'RFC1738' | 'RFC3986'; |
| 28 | formatter?: (str: PropertyKey) => string; |
| 29 | encodeValuesOnly?: boolean; |
| 30 | addQueryPrefix?: boolean; |
| 31 | charset?: 'utf-8' | 'iso-8859-1'; |
| 32 | charsetSentinel?: boolean; |
| 33 | allowEmptyArrays?: boolean; |
| 34 | commaRoundTrip?: boolean; |
| 35 | }; |
| 36 | |
| 37 | export type StringifyOptions = StringifyBaseOptions; |
| 38 | |
| 39 | export type ParseBaseOptions = { |
| 40 | comma?: boolean; |
| 41 | delimiter?: string | RegExp; |
| 42 | depth?: number | false; |
| 43 | decoder?: (str: string, defaultDecoder: DefaultDecoder, charset: string, type: 'key' | 'value') => any; |
| 44 | arrayLimit?: number; |
| 45 | parseArrays?: boolean; |
| 46 | plainObjects?: boolean; |
| 47 | allowPrototypes?: boolean; |
| 48 | allowSparse?: boolean; |
| 49 | parameterLimit?: number; |
| 50 | strictDepth?: boolean; |
| 51 | strictNullHandling?: boolean; |
| 52 | ignoreQueryPrefix?: boolean; |
| 53 | charset?: 'utf-8' | 'iso-8859-1'; |
| 54 | charsetSentinel?: boolean; |
| 55 | interpretNumericEntities?: boolean; |
| 56 | allowEmptyArrays?: boolean; |
| 57 | duplicates?: 'combine' | 'first' | 'last'; |
| 58 | allowDots?: boolean; |
| 59 | decodeDotInKeys?: boolean; |
| 60 | }; |
| 61 | |
| 62 | export type ParseOptions = ParseBaseOptions; |
| 63 | |
| 64 | export type ParsedQs = { |
| 65 | [key: string]: undefined | string | string[] | ParsedQs | ParsedQs[]; |
| 66 | }; |
| 67 | |
| 68 | // Type to remove null or undefined union from each property |
| 69 | export type NonNullableProperties<T> = { |
| 70 | [K in keyof T]-?: Exclude<T[K], undefined | null>; |
| 71 | }; |
| 72 | |