@codeleap/types 6.2.3 → 6.8.0

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.
@@ -0,0 +1,94 @@
1
+ import { DeepPartial, Matcher, LogType } from '.';
2
+ /**
3
+ * Global configuration contract for a CodeLeap product.
4
+ * Every field is deeply optional so that apps only declare what they need;
5
+ * the runtime layer is responsible for supplying sensible defaults for
6
+ * any omitted fields.
7
+ */
8
+ export type AppSettings = DeepPartial<{
9
+ AppName: string;
10
+ CompanyName: string;
11
+ CompanySuffix: string;
12
+ Description: string;
13
+ Environment: {
14
+ IsDev: boolean;
15
+ Type: 'production' | 'development';
16
+ InitTime: any;
17
+ };
18
+ Application: {
19
+ IsBrowser: boolean;
20
+ };
21
+ BaseURL: string;
22
+ Sentry: {
23
+ enable: boolean;
24
+ dsn: string;
25
+ provider: any;
26
+ debug?: boolean;
27
+ initArgs?: any;
28
+ beforeBreadcrumb?: any;
29
+ };
30
+ PerformanceInspector: {
31
+ enable: boolean;
32
+ maxRenders: number;
33
+ blacklist?: string[];
34
+ };
35
+ Logger: {
36
+ Level: LogType | LogType[];
37
+ DeviceIdentifier?: string;
38
+ IgnoreWarnings?: string[];
39
+ StringifyObjects?: boolean;
40
+ isMain?: boolean;
41
+ inspect?: any;
42
+ alwaysSendToSentry?: boolean;
43
+ Obfuscate: {
44
+ keys: Matcher<'key'>[];
45
+ values: Matcher<'value'>[];
46
+ };
47
+ };
48
+ Vars: {
49
+ GooglePlayURL: string;
50
+ AppStoreURL: string;
51
+ WebsiteURL: string;
52
+ PrivacyPolicy: string;
53
+ };
54
+ Fetch: {
55
+ ProductionURL: string;
56
+ DevelopmentURL: string;
57
+ };
58
+ Social: {
59
+ FaceURL: string;
60
+ LinkedinURL: string;
61
+ };
62
+ ContactINFO: {
63
+ Website: string;
64
+ TermsAndPrivacy: string;
65
+ SupportEMAIL: string;
66
+ ContactEMAIL: string;
67
+ ContactPHONE: string;
68
+ };
69
+ ApiCredentials: {
70
+ GoogleSignin: {
71
+ WebClientId: string;
72
+ };
73
+ FacebookSDK: {
74
+ AppId: string;
75
+ };
76
+ };
77
+ Slack: {
78
+ echo: {
79
+ channel?: string;
80
+ icon: string;
81
+ token: string;
82
+ baseURL?: string;
83
+ enabled?: boolean;
84
+ options?: Record<string, any>;
85
+ };
86
+ };
87
+ }>;
88
+ /**
89
+ * The subset of `AppSettings` that is safe to mutate at runtime
90
+ * (e.g. by environment-specific config files or feature flags).
91
+ * Structural settings such as app identity are intentionally excluded.
92
+ */
93
+ export type ConfigurableSettings = Pick<AppSettings, 'Fetch' | 'Logger' | 'ApiCredentials'>;
94
+ //# sourceMappingURL=appSettings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appSettings.d.ts","sourceRoot":"","sources":["../src/appSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,CAAA;AAEjD;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,WAAW,CAAC;IACpC,OAAO,EAAE,MAAM,CAAA;IAEf,WAAW,EAAE,MAAM,CAAA;IAEnB,aAAa,EAAE,MAAM,CAAA;IAErB,WAAW,EAAE,MAAM,CAAA;IAEnB,WAAW,EAAE;QACX,KAAK,EAAE,OAAO,CAAA;QACd,IAAI,EAAE,YAAY,GAAG,aAAa,CAAA;QAClC,QAAQ,EAAE,GAAG,CAAA;KACd,CAAA;IAED,WAAW,EAAE;QACX,SAAS,EAAE,OAAO,CAAA;KACnB,CAAA;IAED,OAAO,EAAE,MAAM,CAAA;IAEf,MAAM,EAAE;QACN,MAAM,EAAE,OAAO,CAAA;QACf,GAAG,EAAE,MAAM,CAAA;QACX,QAAQ,EAAE,GAAG,CAAA;QACb,KAAK,CAAC,EAAE,OAAO,CAAA;QACf,QAAQ,CAAC,EAAE,GAAG,CAAA;QACd,gBAAgB,CAAC,EAAE,GAAG,CAAA;KACvB,CAAA;IAED,oBAA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,IAAI,EAAE;YACJ,OAAO,CAAC,EAAE,MAAM,CAAA;YAChB,IAAI,EAAE,MAAM,CAAA;YACZ,KAAK,EAAE,MAAM,CAAA;YACb,OAAO,CAAC,EAAE,MAAM,CAAA;YAChB,OAAO,CAAC,EAAE,OAAO,CAAA;YACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;SAC9B,CAAA;KACF,CAAA;CACF,CAAC,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,WAAW,EACX,OAAO,GAAG,QAAQ,GAAG,gBAAgB,CACtC,CAAA"}
@@ -0,0 +1,30 @@
1
+ /** A `Promise<T>` that may carry an optional `abort()` method for cancellation (e.g. wrapping an `AbortController`). */
2
+ export type CancellablePromise<T> = Promise<T> & {
3
+ abort?: () => void;
4
+ };
5
+ /** A browser `File` paired with an object-URL preview string. The preview must be revoked with `URL.revokeObjectURL` when no longer needed. */
6
+ export type WebInputFile = {
7
+ file: File;
8
+ preview: string;
9
+ };
10
+ type MobileFileBase = {
11
+ fileCopyUri?: string;
12
+ name: string;
13
+ size: number;
14
+ type: string;
15
+ uri: string;
16
+ };
17
+ /**
18
+ * React Native file descriptor, based on the shape returned by `react-native-document-picker`.
19
+ * The `Extra` parameter lets callers bolt on additional fields while omitting any that conflict with the base shape.
20
+ */
21
+ export type MobileFile<Extra = {}> = Omit<MobileFileBase, keyof Extra> & Partial<Extra>;
22
+ /** A `MobileFile` paired with a local preview URI (e.g. a `file://` path or data URL). */
23
+ export type FileWithPreview<Extra = {}> = {
24
+ file: MobileFile<Extra>;
25
+ preview: string;
26
+ };
27
+ /** Accepts either a bare `MobileFile` or a `FileWithPreview`. Use when a handler must cope with both the raw-pick and post-preview states. */
28
+ export type MobileInputFile<Extra = {}> = FileWithPreview<Extra> | MobileFile<Extra>;
29
+ export {};
30
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":"AAAA,wHAAwH;AACxH,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,IAAI,CAAA;CAAE,CAAA;AAEvE,+IAA+I;AAC/I,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,IAAI,CAAA;IACV,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,KAAK,cAAc,GAAG;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,KAAK,GAAG,EAAE,IAAI,IAAI,CAAC,cAAc,EAAE,MAAM,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;AAEvF,0FAA0F;AAC1F,MAAM,MAAM,eAAe,CAAC,KAAK,GAAG,EAAE,IAAI;IACxC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IACvB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,8IAA8I;AAC9I,MAAM,MAAM,eAAe,CAAC,KAAK,GAAG,EAAE,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,CAAA"}
@@ -0,0 +1,102 @@
1
+ /** A single component of a structured address (e.g. city, country, postal code), as returned by the Google Places API. */
2
+ export type AddressComponent = {
3
+ long_name: string;
4
+ short_name: string;
5
+ types: string[];
6
+ };
7
+ /** A geographic coordinate pair. */
8
+ export type LatLng = {
9
+ lat: number;
10
+ lng: number;
11
+ };
12
+ /** A rectangular bounding box defined by its northeast and southwest corners. */
13
+ export type GeometryBounds = {
14
+ northeast: LatLng;
15
+ southwest: LatLng;
16
+ };
17
+ /** Spatial metadata for a place: its precise location, geocode type, and recommended viewport. */
18
+ export type Geometry = {
19
+ location: LatLng;
20
+ location_type: string;
21
+ viewport: GeometryBounds;
22
+ };
23
+ /** An Open Location Code (OLC) for a place, in both compound (human-readable) and global forms. */
24
+ export type PlusCode = {
25
+ compound_code: string;
26
+ global_code: string;
27
+ };
28
+ /** Identifies a run of characters within an autocomplete suggestion that matched the user's query. */
29
+ export type MatchedSubstring = {
30
+ length: number;
31
+ offset: number;
32
+ };
33
+ /** A token in the structured breakdown of an autocomplete prediction (e.g. city, country). */
34
+ export type Term = {
35
+ offset: number;
36
+ value: string;
37
+ };
38
+ /** A reference to a place photo hosted by Google. Use `photo_reference` to fetch the image via the Places Photo API. */
39
+ export type Photo = {
40
+ height: number;
41
+ html_attributions: string[];
42
+ photo_reference: string;
43
+ width: number;
44
+ };
45
+ /**
46
+ * Full detail record for a resolved place, as returned by the Places Details endpoint.
47
+ * `photos` and `website` are not guaranteed — some places (e.g. cities) omit them.
48
+ */
49
+ export type PlaceDetails = {
50
+ address_components: AddressComponent[];
51
+ adr_address: string;
52
+ formatted_address: string;
53
+ geometry: Geometry;
54
+ icon: string;
55
+ icon_background_color: string;
56
+ icon_mask_base_uri: string;
57
+ name: string;
58
+ place_id: string;
59
+ reference: string;
60
+ types: string[];
61
+ url: string;
62
+ utc_offset: number;
63
+ vicinity: string;
64
+ photos?: Photo[];
65
+ website?: string;
66
+ };
67
+ /** `PlaceDetails` extended with a `plus_code` — present when the geocoder can assign an OLC to the result. */
68
+ export type PlaceLatLngDetails = PlaceDetails & {
69
+ plus_code: PlusCode;
70
+ };
71
+ /**
72
+ * An autocomplete prediction from the Places Autocomplete API.
73
+ * `details` is populated only after a subsequent Details lookup is performed for this prediction.
74
+ */
75
+ export type PlaceAddress = {
76
+ description: string;
77
+ matched_substrings: MatchedSubstring[];
78
+ place_id: string;
79
+ reference: string;
80
+ structured_formatting: {
81
+ main_text: string;
82
+ main_text_matched_substrings: MatchedSubstring[];
83
+ secondary_text: string;
84
+ };
85
+ terms: Term[];
86
+ types: string[];
87
+ details?: PlaceDetails;
88
+ };
89
+ /**
90
+ * A reverse-geocoding result keyed by coordinates rather than a place ID.
91
+ * `details` is populated only after an explicit Details lookup.
92
+ */
93
+ export type PlaceLatLng = {
94
+ address_components: AddressComponent[];
95
+ formatted_address: string;
96
+ geometry: Geometry;
97
+ place_id: string;
98
+ plus_code: PlusCode;
99
+ types: string[];
100
+ details?: PlaceLatLngDetails;
101
+ };
102
+ //# sourceMappingURL=google-places.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-places.d.ts","sourceRoot":"","sources":["../src/google-places.ts"],"names":[],"mappings":"AAAA,0HAA0H;AAC1H,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB,CAAA;AAED,oCAAoC;AACpC,MAAM,MAAM,MAAM,GAAG;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,iFAAiF;AACjF,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,kGAAkG;AAClG,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,EAAE,MAAM,CAAA;IAChB,aAAa,EAAE,MAAM,CAAA;IACrB,QAAQ,EAAE,cAAc,CAAA;CACzB,CAAA;AAED,mGAAmG;AACnG,MAAM,MAAM,QAAQ,GAAG;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAED,sGAAsG;AACtG,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,8FAA8F;AAC9F,MAAM,MAAM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AAE,MAAM,CAAA;KACvB,CAAA;IACD,KAAK,EAAE,IAAI,EAAE,CAAA;IACb,KAAK,EAAE,MAAM,EAAE,CAAA;IAEf,OAAO,CAAC,EAAE,YAAY,CAAA;CACvB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,kBAAkB,EAAE,gBAAgB,EAAE,CAAA;IACtC,iBAAiB,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,QAAQ,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,QAAQ,CAAA;IACnB,KAAK,EAAE,MAAM,EAAE,CAAA;IAEf,OAAO,CAAC,EAAE,kBAAkB,CAAA;CAC7B,CAAA"}
@@ -0,0 +1,8 @@
1
+ export * from './google-places';
2
+ export * from './pathMapping';
3
+ export * from './utility';
4
+ export * from './common';
5
+ export * as TypeGuards from './typeGuards';
6
+ export * from './appSettings';
7
+ export * as RNMaskedTextTypes from './react-native-masked-text';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,UAAU,CAAA;AACxB,OAAO,KAAK,UAAU,MAAM,cAAc,CAAA;AAC1C,cAAc,eAAe,CAAA;AAC7B,OAAO,KAAK,iBAAiB,MAAM,4BAA4B,CAAA"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Lookup table that maps a depth counter `N` to `N - 1`.
3
+ * Used to decrement the recursion depth in types like `Paths` and `ReplaceRecursive`.
4
+ * Terminates at `0 → never` to halt infinite recursion.
5
+ */
6
+ export type Prev = [
7
+ never,
8
+ 0,
9
+ 1,
10
+ 2,
11
+ 3,
12
+ 4,
13
+ 5,
14
+ 6,
15
+ 7,
16
+ 8,
17
+ 9,
18
+ 10,
19
+ 11,
20
+ 12,
21
+ 13,
22
+ 14,
23
+ 15,
24
+ 16,
25
+ 17,
26
+ 18,
27
+ 19,
28
+ 20,
29
+ ...0[]
30
+ ];
31
+ /**
32
+ * Concatenates two path segments with a `.` separator.
33
+ * Produces an empty junction when `P` is an empty string (root key case).
34
+ */
35
+ export type Join<K, P> = K extends string | number ? P extends string | number ? `${K}${'' extends P ? '' : '.'}${P}` : never : never;
36
+ /**
37
+ * Recursively generates all valid dot-notation path strings for an object type `T`.
38
+ * Stops at `Date` values (treating them as leaves) and at depth `D` (default 2).
39
+ * Includes both the parent key and all descendant paths via `Join`.
40
+ */
41
+ export type Paths<T, D extends number = 2> = [D] extends [never] ? never : (T extends Date ? '' : (T extends object ? {
42
+ [K in keyof T]-?: K extends string | number ? `${K}` | Join<K, Paths<T[K], Prev[D]>> : never;
43
+ }[keyof T] : ''));
44
+ /**
45
+ * Like `Paths` but unbounded in depth and always treats every object as
46
+ * a traversable node (no `Date` short-circuit). Prefer `Paths` for large
47
+ * or deeply nested types to avoid hitting the TS recursion limit.
48
+ */
49
+ export type ExtractPath<T> = T extends object ? {
50
+ [K in keyof T & (string | number)]: T[K] extends object ? `${K}` | `${K}.${ExtractPath<T[K]>}` : `${K}`;
51
+ }[keyof T & (string | number)] : never;
52
+ //# sourceMappingURL=pathMapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pathMapping.d.ts","sourceRoot":"","sources":["../src/pathMapping.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,IAAI,GAAG;IACjB,KAAK;IACL,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,GAAG,CAAC,EAAE;CACP,CAAA;AAED;;;GA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credit-card' | 'cpf' | 'cnpj' | 'zip-code' | 'only-numbers' | 'money' | 'cel-phone' | 'datetime' | 'custom';
3
+ /**
4
+ * Format options for `TextInputMask`. Which fields are relevant depends on the active `type`:
5
+ * - **money** — `precision`, `separator`, `delimiter`, `unit`, `suffixUnit`, `zeroCents`
6
+ * - **cel-phone** — `withDDD`, `dddMask`, `maskType`
7
+ * - **datetime** — `format` (moment.js pattern)
8
+ * - **credit-card** — `obfuscated`, `issuer`
9
+ * - **custom** — `mask`, `validator`, `getRawValue`, `translation`
10
+ */
11
+ export interface TextInputMaskOptionProp {
12
+ precision?: number;
13
+ separator?: string;
14
+ delimiter?: string;
15
+ unit?: string;
16
+ suffixUnit?: string;
17
+ zeroCents?: boolean;
18
+ withDDD?: boolean;
19
+ dddMask?: string;
20
+ maskType?: 'BRL' | 'INTERNATIONAL';
21
+ format?: string;
22
+ obfuscated?: boolean;
23
+ issuer?: 'visa-or-mastercard' | 'diners' | 'amex';
24
+ mask?: string;
25
+ validator?: (value: string, settings: TextInputMaskOptionProp) => boolean;
26
+ getRawValue?: (value: string, settings: TextInputMaskOptionProp) => any;
27
+ translation?: {
28
+ [s: string]: (val: string) => string | null | undefined;
29
+ };
30
+ }
31
+ /**
32
+ * Props for the `TextInputMask` component from `react-native-masked-text`.
33
+ * Set `includeRawValueInChangeText` to receive the unmasked value alongside the formatted one in `onChangeText`.
34
+ */
35
+ export interface TextInputMaskProps {
36
+ type: TextInputMaskTypeProp;
37
+ options?: TextInputMaskOptionProp;
38
+ checkText?: (previous: string, next: string) => boolean;
39
+ customTextInput?: any;
40
+ customTextInputProps?: Object;
41
+ includeRawValueInChangeText?: boolean;
42
+ }
43
+ //# sourceMappingURL=react-native-masked-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-native-masked-text.d.ts","sourceRoot":"","sources":["../src/react-native-masked-text.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,MAAM,MAAM,qBAAqB,GAC3B,aAAa,GACb,K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CAAC,EAAE,MAAM,CAAA;IAC7B,2BAA2B,CAAC,EAAE,OAAO,CAAA;CACxC"}
@@ -0,0 +1,31 @@
1
+ import { AnyFunction } from './utility';
2
+ import React from 'react';
3
+ export declare function isNumber(x: unknown): x is number;
4
+ export declare function isString(x: unknown): x is string;
5
+ /** Returns `true` for any value whose `typeof` is `'object'`, including `null`. Pair with `isNil` when null must be excluded. */
6
+ export declare function isObject(x: unknown): x is object;
7
+ export declare function isBoolean(x: unknown): x is boolean;
8
+ export declare function isFunction(x: unknown): x is (AnyFunction);
9
+ /** Checks callable shape only — does not distinguish between regular functions and class constructors. Use `isConstructor` when the `new` signature matters. */
10
+ export declare function isConstructor(x: unknown): x is (new (...args: unknown[]) => any);
11
+ export declare function isArray(x: unknown): x is any[];
12
+ export declare function isUndefined(x: unknown): x is undefined;
13
+ export declare function isNull(x: unknown): x is null;
14
+ export declare function isNil(x: unknown): x is null | undefined;
15
+ /** Checks membership of `x` in the `Enum` array — useful for narrowing to a specific string/number literal union at runtime. */
16
+ export declare function is<T>(x: unknown, Enum: T[]): x is T;
17
+ type Abstract<T> = Function & {
18
+ prototype: T;
19
+ };
20
+ type Constructor<T> = new (...args: any[]) => T;
21
+ type Class<T = any> = Abstract<T> | Constructor<T>;
22
+ /** Works for both concrete classes and abstract classes via the `Abstract<T>` branch. */
23
+ export declare function isInstance<T extends Class, X = T extends Class<infer X> ? X : never>(x: unknown, cls: T): x is X;
24
+ /** Delegates to `React.isValidElement` — returns `true` for JSX elements but `false` for plain components (functions/classes). */
25
+ export declare function isElement(x: unknown): x is React.ReactElement;
26
+ /** Accepts both a component type (function/class) and a rendered element — use when a prop can receive either form. */
27
+ export declare function isComponentOrElement<P>(x: any): x is React.ComponentType<P> | React.ReactElement;
28
+ /** Duck-types against `.then` and `.catch` rather than `instanceof Promise`, so it works across realms and custom thenables. */
29
+ export declare function isPromise(x: unknown): x is Promise<any>;
30
+ export {};
31
+ //# sourceMappingURL=typeGuards.d.ts.map
@@ -0,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AAC,CAAA;CAAC,CAAA;AAE5C,KAAK,WAAW,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAA;AAC/C,KAAK,KAAK,CAAC,CAAC,GAAG,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;AAElD,yFAAyF;AACzF,wBAAgB,UAAU,CAAC,CAAC,SAAS,KAAK,EAAE,CAAC,GAAG,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAEhH;AAED,kIAAkI;AAClI,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,KAAK,CAAC,YAAY,CAE7D;AAED,uHAAuH;AACvH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,GAAG,CAAC,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,YAAY,CAEhG;AAED,gIAAgI;AAChI,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAEvD"}
@@ -0,0 +1,136 @@
1
+ import { ReactNode } from 'react';
2
+ import { Prev } from './pathMapping';
3
+ /** Matches any callable — use as a constraint, not as a call signature. */
4
+ export type AnyFunction = (...args: any[]) => any;
5
+ /** Matches any `Record<string, any>`. Useful as a generic object constraint. */
6
+ export type AnyRecord = Record<string, any>;
7
+ /** Constrains a record whose values must all be strings. */
8
+ export type StringRecord = Record<string, string>;
9
+ /** Makes every property in `T` `readonly` shallowly. Prefer this over the built-in `Readonly<T>` only when you need the mapped-type form for composability. */
10
+ export type ReadOnly<T> = {
11
+ readonly [Property in keyof T]: T[Property];
12
+ };
13
+ /** Collects the keys of every nested object value in `T`. Only one level deep — grandchildren are not included. */
14
+ export type NestedKeys<T> = {
15
+ [K in keyof T]: T[K] extends Record<any, any> ? keyof T[K] : never;
16
+ }[keyof T];
17
+ /** Typed function with explicit `Args` and `Return` — use instead of `AnyFunction` when the signature matters. */
18
+ export type FunctionType<Args extends any[], Return> = (...args: Args) => Return;
19
+ /**
20
+ * Recursively makes every property optional.
21
+ * `null` and `RegExp` values are widened to `any` to avoid
22
+ * their structural members being partially unwrapped.
23
+ */
24
+ export type DeepPartial<T> = Partial<{
25
+ [Property in keyof T]: T[Property] extends Record<string, any> ? T[Property] extends null | RegExp ? any : DeepPartial<T[Property]> : T[Property] extends null | RegExp ? any : Partial<T[Property]>;
26
+ }>;
27
+ type PrependNextNum<A extends Array<unknown>> = A['length'] extends infer T ? ((t: T, ...a: A) => void) extends (...x: infer X) => void ? X : never : never;
28
+ type EnumerateInternal<A extends Array<unknown>, N extends number> = {
29
+ 0: A;
30
+ 1: EnumerateInternal<PrependNextNum<A>, N>;
31
+ }[N extends A['length'] ? 0 : 1];
32
+ /**
33
+ * Produces a union of integers from `0` up to (but not including) `N`.
34
+ * Useful for constraining numeric literals without listing them by hand.
35
+ * @example `Enumerate<5>` → `0 | 1 | 2 | 3 | 4`
36
+ */
37
+ export type Enumerate<N extends number> = EnumerateInternal<[
38
+ ], N> extends (infer E)[] ? E : never;
39
+ /**
40
+ * Produces a union of integers in the half-open interval `[FROM, TO)`.
41
+ * @example `Range<2, 5>` → `2 | 3 | 4`
42
+ */
43
+ export type Range<FROM extends number, TO extends number> = Exclude<Enumerate<TO>, Enumerate<FROM>>;
44
+ /** Maps each key of a component/variant union `C` to an optional CSS value. Used to type per-variant style overrides. */
45
+ export type StylesOf<C extends string | number | symbol = any, CSS = any> = Partial<Record<C, CSS>>;
46
+ type IsDict<T> = T extends AnyFunction ? false : T extends Record<string, any> ? true : false;
47
+ /**
48
+ * Walks every property of `T` and replaces occurrences of `Replace` with `With`.
49
+ * The depth counter `D` (default 10) prevents infinite recursion on circular types.
50
+ * Functions are left untouched even if they satisfy the `Replace` constraint.
51
+ */
52
+ export type ReplaceRecursive<T, Replace, With, D extends number = 10> = [D] extends [never] ? never : {
53
+ [Property in keyof T]: T[Property] extends Replace ? With : IsDict<T[Property]> extends true ? ReplaceRecursive<T[Property], Replace, With, Prev[D]> : T[Property];
54
+ };
55
+ /**
56
+ * Like `Omit<T, K>` but preserves the exact property types without the
57
+ * homomorphic mapped-type widening that `Omit` can introduce on complex generics.
58
+ */
59
+ export type SmartOmit<T, K extends keyof T> = {
60
+ [Property in Exclude<keyof T, K>]: T[Property];
61
+ };
62
+ /** Extracts the props type of a React component `T`, optionally omitting keys listed in `Exclude`. */
63
+ export type PropsOf<T, Exclude extends string = ''> = T extends React.ComponentType<infer P> ? Omit<P, Exclude> : any;
64
+ /** A dictionary with string keys and homogeneous values of type `T`. Prefer over `Record<string, T>` when the key set is unknown at compile time. */
65
+ export type Hashmap<T> = {
66
+ [key: string]: T;
67
+ };
68
+ /** Unwraps the resolved value of a `Promise<U>`. Passes non-promise types through unchanged. */
69
+ export type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
70
+ /** Extracts the resolved return type of an async function. Returns `never` for non-async functions. */
71
+ export type AsyncReturnType<T> = T extends (...args: any[]) => Promise<infer U> ? U : never;
72
+ /**
73
+ * Extracts the `variants` prop type from a component that accepts `{ variants: V }`.
74
+ * Falls back to `string[]` when the inferred type is not a string or string array.
75
+ */
76
+ export type VariantsOf<T> = T extends ((props: {
77
+ variants: infer V;
78
+ }) => any) ? (V extends (string | string[]) ? V : (string[])) : (string[]);
79
+ /** Strips `string` from a union, leaving only the non-string literal members. Useful for extracting enum-like members from a mixed union. */
80
+ export type VariantList<T> = Exclude<T, string>;
81
+ /** Unwraps the element type that a `React.Ref<U>` points to. */
82
+ export type GetRefType<T> = T extends React.Ref<infer U> ? U : never;
83
+ /**
84
+ * Returns a union of the keys of `T` whose value type extends `Filter`.
85
+ * Uses a sentinel string `'__never__'` internally to avoid distributing `never` in the union.
86
+ */
87
+ export type FilterKeys<T, Filter = any> = Exclude<{
88
+ [P in keyof T]: T[P] extends Filter ? P : '__never__';
89
+ }[keyof T], '__never__'>;
90
+ /** The tuple returned by `React.useState<T>()` — useful for passing state as a single prop. */
91
+ export type ReactState<T = any> = [
92
+ T,
93
+ React.Dispatch<React.SetStateAction<T>>
94
+ ];
95
+ /**
96
+ * Expands a state tuple into a props object with the value key and a `set<Name>` setter key.
97
+ * @example `ReactStateProps<'count', number>` → `{ count: number; setCount: Dispatch<...> }`
98
+ */
99
+ export type ReactStateProps<Name extends string, T = any, State extends ReactState<T> = ReactState<T>> = {
100
+ [P in Name as `set${Capitalize<Name>}`]: State[1];
101
+ } & {
102
+ [P in Name]: State[0];
103
+ };
104
+ /** Union of every ref shape React accepts — callback refs, `MutableRefObject`, `ForwardedRef`, and the legacy form. Use when a utility must accept any ref flavour. */
105
+ export type AnyRef<T> = React.Ref<T> | React.MutableRefObject<T> | ((instance: T | null) => void) | null | React.ForwardedRef<T> | React.LegacyRef<T>;
106
+ /** Produces a union of valid indices for a readonly tuple `T`. Excludes the `length` value itself. */
107
+ export type Indices<T extends readonly any[]> = Exclude<Partial<T>['length'], T['length']>;
108
+ /** Replaces the types of specific keys `Keys` in `Object` with `With`, leaving all other keys intact. */
109
+ export type Replace<Object, Keys extends keyof Object, With = any> = Omit<Object, Keys> & {
110
+ [P in Keys]: With;
111
+ };
112
+ /**
113
+ * Flexible predicate type used for filtering or matching.
114
+ * Accepts a plain string, a partial `RegExp` descriptor, or a two-argument predicate
115
+ * that receives the value/key and a type discriminant `T`.
116
+ */
117
+ export type Matcher<T> = string | Partial<RegExp> | FunctionType<[valueOrKey: any, type: T], boolean>;
118
+ /** Logger severity levels, including `'silent'` to suppress all output. */
119
+ export type LogType = 'info' | 'debug' | 'warn' | 'error' | 'log' | 'silent';
120
+ /** Drops the first argument of a function and returns the remaining parameter types. */
121
+ export type SecondToLastArguments<T extends AnyFunction> = T extends ((...args: [infer _, ...infer Rest]) => any) ? Rest : never;
122
+ /** An array of `{ label, value }` pairs — the canonical shape for select/dropdown data sources. */
123
+ export type Options<T> = {
124
+ label: string;
125
+ value: T;
126
+ }[];
127
+ /** A single entry from an `Options<T>` array. */
128
+ export type Option<T> = Options<T>[number];
129
+ /** A label that can be a plain string or any React-renderable node. */
130
+ export type Label = string | ReactNode;
131
+ /** Union of all value types in `T`. Equivalent to `T[keyof T]`. */
132
+ export type ValueOf<T> = T[keyof T];
133
+ /** Alias for `keyof T` — useful when you need to pass the key union as a generic argument. */
134
+ export type Keyof<T> = keyof T;
135
+ export {};
136
+ //# sourceMappingURL=utility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../src/utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAGpC,2EAA2E;AAC3E,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAA;AAEjD,gFAAgF;AAChF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;AAE3C,4DAA4D;AAC5D,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAEjD,+JAA+J;AAC/J,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI;IACxB,QAAQ,EAAE,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;CAC5C,CAAA;AAED,mHAAmH;AACnH,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;KACzB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;CACnE,CAAC,MAAM,CAAC,C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
- "version": "6.2.3",
3
+ "version": "6.8.0",
4
4
  "main": "src/index.ts",
5
+ "types": "dist/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "source": "./src/index.ts",
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "src"
17
+ ],
5
18
  "license": "UNLICENSED",
6
19
  "repository": {
7
20
  "url": "https://github.com/codeleap-uk/internal-libs-monorepo.git",
@@ -9,14 +22,15 @@
9
22
  "directory": "packages/types"
10
23
  },
11
24
  "devDependencies": {
12
- "@codeleap/config": "6.2.3",
25
+ "@codeleap/config": "6.8.0",
13
26
  "ts-node-dev": "1.1.8"
14
27
  },
15
28
  "scripts": {
16
- "build": "echo 'No build needed'"
29
+ "build": "tsc --build tsconfig.build.json",
30
+ "typecheck": "bun tsc --noEmit -p ./tsconfig.json"
17
31
  },
18
32
  "peerDependencies": {
19
- "typescript": "5.5.2",
33
+ "typescript": "6.0.3",
20
34
  "react": "19.1.0"
21
35
  }
22
- }
36
+ }
@@ -1,8 +1,14 @@
1
1
  import { DeepPartial, Matcher, LogType } from '.'
2
2
 
3
+ /**
4
+ * Global configuration contract for a CodeLeap product.
5
+ * Every field is deeply optional so that apps only declare what they need;
6
+ * the runtime layer is responsible for supplying sensible defaults for
7
+ * any omitted fields.
8
+ */
3
9
  export type AppSettings = DeepPartial<{
4
10
  AppName: string
5
-
11
+
6
12
  CompanyName: string
7
13
 
8
14
  CompanySuffix: string
@@ -96,6 +102,11 @@ export type AppSettings = DeepPartial<{
96
102
  }
97
103
  }>
98
104
 
105
+ /**
106
+ * The subset of `AppSettings` that is safe to mutate at runtime
107
+ * (e.g. by environment-specific config files or feature flags).
108
+ * Structural settings such as app identity are intentionally excluded.
109
+ */
99
110
  export type ConfigurableSettings = Pick<
100
111
  AppSettings,
101
112
  'Fetch' | 'Logger' | 'ApiCredentials'
package/src/common.ts CHANGED
@@ -1,5 +1,7 @@
1
+ /** A `Promise<T>` that may carry an optional `abort()` method for cancellation (e.g. wrapping an `AbortController`). */
1
2
  export type CancellablePromise<T> = Promise<T> & { abort?: () => void }
2
3
 
4
+ /** A browser `File` paired with an object-URL preview string. The preview must be revoked with `URL.revokeObjectURL` when no longer needed. */
3
5
  export type WebInputFile = {
4
6
  file: File
5
7
  preview: string
@@ -13,11 +15,17 @@ type MobileFileBase = {
13
15
  uri: string
14
16
  }
15
17
 
18
+ /**
19
+ * React Native file descriptor, based on the shape returned by `react-native-document-picker`.
20
+ * The `Extra` parameter lets callers bolt on additional fields while omitting any that conflict with the base shape.
21
+ */
16
22
  export type MobileFile<Extra = {}> = Omit<MobileFileBase, keyof Extra> & Partial<Extra>
17
23
 
24
+ /** A `MobileFile` paired with a local preview URI (e.g. a `file://` path or data URL). */
18
25
  export type FileWithPreview<Extra = {}> = {
19
26
  file: MobileFile<Extra>
20
27
  preview: string
21
28
  }
22
29
 
30
+ /** Accepts either a bare `MobileFile` or a `FileWithPreview`. Use when a handler must cope with both the raw-pick and post-preview states. */
23
31
  export type MobileInputFile<Extra = {}> = FileWithPreview<Extra> | MobileFile<Extra>
@@ -1,40 +1,48 @@
1
+ /** A single component of a structured address (e.g. city, country, postal code), as returned by the Google Places API. */
1
2
  export type AddressComponent = {
2
3
  long_name: string
3
4
  short_name: string
4
5
  types: string[]
5
6
  }
6
7
 
8
+ /** A geographic coordinate pair. */
7
9
  export type LatLng = {
8
10
  lat: number
9
11
  lng: number
10
12
  }
11
13
 
14
+ /** A rectangular bounding box defined by its northeast and southwest corners. */
12
15
  export type GeometryBounds = {
13
16
  northeast: LatLng
14
17
  southwest: LatLng
15
18
  }
16
19
 
20
+ /** Spatial metadata for a place: its precise location, geocode type, and recommended viewport. */
17
21
  export type Geometry = {
18
22
  location: LatLng
19
23
  location_type: string
20
24
  viewport: GeometryBounds
21
25
  }
22
26
 
27
+ /** An Open Location Code (OLC) for a place, in both compound (human-readable) and global forms. */
23
28
  export type PlusCode = {
24
29
  compound_code: string
25
30
  global_code: string
26
31
  }
27
32
 
33
+ /** Identifies a run of characters within an autocomplete suggestion that matched the user's query. */
28
34
  export type MatchedSubstring = {
29
35
  length: number
30
36
  offset: number
31
37
  }
32
38
 
39
+ /** A token in the structured breakdown of an autocomplete prediction (e.g. city, country). */
33
40
  export type Term = {
34
41
  offset: number
35
42
  value: string
36
43
  }
37
44
 
45
+ /** A reference to a place photo hosted by Google. Use `photo_reference` to fetch the image via the Places Photo API. */
38
46
  export type Photo = {
39
47
  height: number
40
48
  html_attributions: string[]
@@ -42,6 +50,10 @@ export type Photo = {
42
50
  width: number
43
51
  }
44
52
 
53
+ /**
54
+ * Full detail record for a resolved place, as returned by the Places Details endpoint.
55
+ * `photos` and `website` are not guaranteed — some places (e.g. cities) omit them.
56
+ */
45
57
  export type PlaceDetails = {
46
58
  address_components: AddressComponent[]
47
59
  adr_address: string
@@ -64,10 +76,15 @@ export type PlaceDetails = {
64
76
  website?: string
65
77
  }
66
78
 
79
+ /** `PlaceDetails` extended with a `plus_code` — present when the geocoder can assign an OLC to the result. */
67
80
  export type PlaceLatLngDetails = PlaceDetails & {
68
81
  plus_code: PlusCode
69
82
  }
70
83
 
84
+ /**
85
+ * An autocomplete prediction from the Places Autocomplete API.
86
+ * `details` is populated only after a subsequent Details lookup is performed for this prediction.
87
+ */
71
88
  export type PlaceAddress = {
72
89
  description: string
73
90
  matched_substrings: MatchedSubstring[]
@@ -84,6 +101,10 @@ export type PlaceAddress = {
84
101
  details?: PlaceDetails
85
102
  }
86
103
 
104
+ /**
105
+ * A reverse-geocoding result keyed by coordinates rather than a place ID.
106
+ * `details` is populated only after an explicit Details lookup.
107
+ */
87
108
  export type PlaceLatLng = {
88
109
  address_components: AddressComponent[]
89
110
  formatted_address: string
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Lookup table that maps a depth counter `N` to `N - 1`.
3
+ * Used to decrement the recursion depth in types like `Paths` and `ReplaceRecursive`.
4
+ * Terminates at `0 → never` to halt infinite recursion.
5
+ */
1
6
  export type Prev = [
2
7
  never,
3
8
  0,
@@ -24,12 +29,21 @@ export type Prev = [
24
29
  ...0[]
25
30
  ]
26
31
 
32
+ /**
33
+ * Concatenates two path segments with a `.` separator.
34
+ * Produces an empty junction when `P` is an empty string (root key case).
35
+ */
27
36
  export type Join<K, P> = K extends string | number
28
37
  ? P extends string | number
29
38
  ? `${K}${'' extends P ? '' : '.'}${P}`
30
39
  : never
31
40
  : never
32
41
 
42
+ /**
43
+ * Recursively generates all valid dot-notation path strings for an object type `T`.
44
+ * Stops at `Date` values (treating them as leaves) and at depth `D` (default 2).
45
+ * Includes both the parent key and all descendant paths via `Join`.
46
+ */
33
47
  export type Paths<T, D extends number = 2> = [D] extends [never]
34
48
  ? never
35
49
  : (T extends Date
@@ -43,6 +57,11 @@ export type Paths<T, D extends number = 2> = [D] extends [never]
43
57
  : '')
44
58
  )
45
59
 
60
+ /**
61
+ * Like `Paths` but unbounded in depth and always treats every object as
62
+ * a traversable node (no `Date` short-circuit). Prefer `Paths` for large
63
+ * or deeply nested types to avoid hitting the TS recursion limit.
64
+ */
46
65
  export type ExtractPath<T> = T extends object
47
66
  ? {
48
67
  [K in keyof T & (string | number)]: T[K] extends object
@@ -1,4 +1,4 @@
1
- // Type prop of TextInputMask.
1
+ /** The mask format to apply. `'custom'` requires a `mask` pattern in `TextInputMaskOptionProp`. */
2
2
  export type TextInputMaskTypeProp =
3
3
  | 'credit-card'
4
4
  | 'cpf'
@@ -10,7 +10,14 @@ export type TextInputMaskTypeProp =
10
10
  | 'datetime'
11
11
  | 'custom'
12
12
 
13
- // Option prop of TextInputMask.
13
+ /**
14
+ * Format options for `TextInputMask`. Which fields are relevant depends on the active `type`:
15
+ * - **money** — `precision`, `separator`, `delimiter`, `unit`, `suffixUnit`, `zeroCents`
16
+ * - **cel-phone** — `withDDD`, `dddMask`, `maskType`
17
+ * - **datetime** — `format` (moment.js pattern)
18
+ * - **credit-card** — `obfuscated`, `issuer`
19
+ * - **custom** — `mask`, `validator`, `getRawValue`, `translation`
20
+ */
14
21
  export interface TextInputMaskOptionProp {
15
22
  // Money type.
16
23
  precision?: number
@@ -39,7 +46,10 @@ export interface TextInputMaskOptionProp {
39
46
  translation?: { [s: string]: (val: string) => string | null | undefined }
40
47
  }
41
48
 
42
- // TextInputMask Props
49
+ /**
50
+ * Props for the `TextInputMask` component from `react-native-masked-text`.
51
+ * Set `includeRawValueInChangeText` to receive the unmasked value alongside the formatted one in `onChangeText`.
52
+ */
43
53
  export interface TextInputMaskProps {
44
54
  type: TextInputMaskTypeProp
45
55
  options?: TextInputMaskOptionProp
@@ -48,4 +58,3 @@ export interface TextInputMaskProps {
48
58
  customTextInputProps?: Object
49
59
  includeRawValueInChangeText?: boolean
50
60
  }
51
-
package/src/typeGuards.ts CHANGED
@@ -1,61 +1,73 @@
1
1
  import { AnyFunction } from './utility'
2
2
  import React from 'react'
3
3
 
4
- export function isNumber(x): x is number {
4
+ export function isNumber(x: unknown): x is number {
5
5
  return typeof x === 'number'
6
6
  }
7
7
 
8
- export function isString(x): x is string {
8
+ export function isString(x: unknown): x is string {
9
9
  return typeof x === 'string'
10
10
  }
11
- export function isObject(x): x is object {
11
+
12
+ /** Returns `true` for any value whose `typeof` is `'object'`, including `null`. Pair with `isNil` when null must be excluded. */
13
+ export function isObject(x: unknown): x is object {
12
14
  return typeof x === 'object'
13
15
  }
14
- export function isBoolean(x): x is boolean {
16
+
17
+ export function isBoolean(x: unknown): x is boolean {
15
18
  return typeof x === 'boolean'
16
19
  }
17
- export function isFunction(x): x is (AnyFunction) {
20
+
21
+ export function isFunction(x: unknown): x is (AnyFunction) {
18
22
  return typeof x === 'function'
19
23
  }
20
24
 
21
- export function isConstructor(x): x is (new (...args) => any) {
25
+ /** Checks callable shape only — does not distinguish between regular functions and class constructors. Use `isConstructor` when the `new` signature matters. */
26
+ export function isConstructor(x: unknown): x is (new (...args: unknown[]) => any) {
22
27
  return typeof x === 'function'
23
28
  }
24
- export function isArray(x): x is any[] {
29
+
30
+ export function isArray(x: unknown): x is any[] {
25
31
  return Array.isArray(x)
26
32
  }
27
- export function isUndefined(x): x is undefined {
33
+
34
+ export function isUndefined(x: unknown): x is undefined {
28
35
  return typeof x === 'undefined'
29
36
  }
30
37
 
31
- export function isNull(x): x is null {
38
+ export function isNull(x: unknown): x is null {
32
39
  return x === null
33
40
  }
34
41
 
35
- export function isNil(x): x is null | undefined {
42
+ export function isNil(x: unknown): x is null | undefined {
36
43
  return isNull(x) || isUndefined(x)
37
44
  }
38
45
 
39
- export function is<T >(x, Enum: T[]): x is T {
40
- return Enum.includes(x)
46
+ /** Checks membership of `x` in the `Enum` array useful for narrowing to a specific string/number literal union at runtime. */
47
+ export function is<T >(x: unknown, Enum: T[]): x is T {
48
+ return Enum.includes(x as T)
41
49
  }
42
50
  type Abstract<T> = Function & {prototype: T}
43
51
 
44
52
  type Constructor<T> = new (...args: any[]) => T
45
53
  type Class<T = any> = Abstract<T> | Constructor<T>
46
54
 
47
- export function isInstance<T extends Class, X = T extends Class<infer X> ? X : never>(x, cls: T): x is X {
48
- return x instanceof cls
55
+ /** Works for both concrete classes and abstract classes via the `Abstract<T>` branch. */
56
+ export function isInstance<T extends Class, X = T extends Class<infer X> ? X : never>(x: unknown, cls: T): x is X {
57
+ return x instanceof (cls as Constructor<X>)
49
58
  }
50
59
 
51
- export function isElement(x): x is React.ReactElement {
60
+ /** Delegates to `React.isValidElement` returns `true` for JSX elements but `false` for plain components (functions/classes). */
61
+ export function isElement(x: unknown): x is React.ReactElement {
52
62
  return React.isValidElement(x)
53
63
  }
54
64
 
65
+ /** Accepts both a component type (function/class) and a rendered element — use when a prop can receive either form. */
55
66
  export function isComponentOrElement<P>(x: any): x is React.ComponentType<P> | React.ReactElement {
56
67
  return isFunction(x) || isElement(x)
57
68
  }
58
69
 
59
- export function isPromise(x): x is Promise<any> {
60
- return isFunction(x?.then) && isFunction(x?.catch)
61
- }
70
+ /** Duck-types against `.then` and `.catch` rather than `instanceof Promise`, so it works across realms and custom thenables. */
71
+ export function isPromise(x: unknown): x is Promise<any> {
72
+ return isFunction((x as any)?.then) && isFunction((x as any)?.catch)
73
+ }
package/src/utility.ts CHANGED
@@ -1,24 +1,36 @@
1
1
  import { ReactNode } from 'react'
2
2
  import { Prev } from './pathMapping'
3
3
  /* eslint-disable no-unused-vars */
4
+
5
+ /** Matches any callable — use as a constraint, not as a call signature. */
4
6
  export type AnyFunction = (...args: any[]) => any
5
7
 
8
+ /** Matches any `Record<string, any>`. Useful as a generic object constraint. */
6
9
  export type AnyRecord = Record<string, any>
7
10
 
11
+ /** Constrains a record whose values must all be strings. */
8
12
  export type StringRecord = Record<string, string>
9
13
 
14
+ /** Makes every property in `T` `readonly` shallowly. Prefer this over the built-in `Readonly<T>` only when you need the mapped-type form for composability. */
10
15
  export type ReadOnly<T> = {
11
16
  readonly [Property in keyof T]: T[Property];
12
17
  }
13
18
 
19
+ /** Collects the keys of every nested object value in `T`. Only one level deep — grandchildren are not included. */
14
20
  export type NestedKeys<T> = {
15
21
  [K in keyof T]: T[K] extends Record<any, any> ? keyof T[K] : never;
16
22
  }[keyof T]
17
23
 
24
+ /** Typed function with explicit `Args` and `Return` — use instead of `AnyFunction` when the signature matters. */
18
25
  export type FunctionType<Args extends any[], Return> = (
19
26
  ...args: Args
20
27
  ) => Return
21
28
 
29
+ /**
30
+ * Recursively makes every property optional.
31
+ * `null` and `RegExp` values are widened to `any` to avoid
32
+ * their structural members being partially unwrapped.
33
+ */
22
34
  export type DeepPartial<T> = Partial<{
23
35
  [Property in keyof T]: T[Property] extends Record<string, any>
24
36
  ? T[Property] extends null|RegExp
@@ -40,6 +52,11 @@ type EnumerateInternal<A extends Array<unknown>, N extends number> = {
40
52
  1: EnumerateInternal<PrependNextNum<A>, N>
41
53
  }[N extends A['length'] ? 0 : 1]
42
54
 
55
+ /**
56
+ * Produces a union of integers from `0` up to (but not including) `N`.
57
+ * Useful for constraining numeric literals without listing them by hand.
58
+ * @example `Enumerate<5>` → `0 | 1 | 2 | 3 | 4`
59
+ */
43
60
  export type Enumerate<N extends number> = EnumerateInternal<
44
61
  [],
45
62
  N
@@ -47,11 +64,16 @@ export type Enumerate<N extends number> = EnumerateInternal<
47
64
  ? E
48
65
  : never
49
66
 
67
+ /**
68
+ * Produces a union of integers in the half-open interval `[FROM, TO)`.
69
+ * @example `Range<2, 5>` → `2 | 3 | 4`
70
+ */
50
71
  export type Range<FROM extends number, TO extends number> = Exclude<
51
72
  Enumerate<TO>,
52
73
  Enumerate<FROM>
53
74
  >
54
75
 
76
+ /** Maps each key of a component/variant union `C` to an optional CSS value. Used to type per-variant style overrides. */
55
77
  export type StylesOf<
56
78
  C extends string | number | symbol = any,
57
79
  CSS = any
@@ -63,6 +85,11 @@ type IsDict<T> = T extends AnyFunction
63
85
  ? true
64
86
  : false
65
87
 
88
+ /**
89
+ * Walks every property of `T` and replaces occurrences of `Replace` with `With`.
90
+ * The depth counter `D` (default 10) prevents infinite recursion on circular types.
91
+ * Functions are left untouched even if they satisfy the `Replace` constraint.
92
+ */
66
93
  export type ReplaceRecursive<T, Replace, With, D extends number = 10> = [D] extends [never] ? never : {
67
94
  [Property in keyof T]: T[Property] extends Replace
68
95
  ? With
@@ -70,64 +97,103 @@ export type ReplaceRecursive<T, Replace, With, D extends number = 10> = [D] exte
70
97
  ? ReplaceRecursive<T[Property], Replace, With, Prev[D]>
71
98
  : T[Property];
72
99
  }
100
+
101
+ /**
102
+ * Like `Omit<T, K>` but preserves the exact property types without the
103
+ * homomorphic mapped-type widening that `Omit` can introduce on complex generics.
104
+ */
73
105
  export type SmartOmit<T, K extends keyof T> = {
74
106
  [Property in Exclude<keyof T, K>]: T[Property];
75
107
  }
76
108
 
109
+ /** Extracts the props type of a React component `T`, optionally omitting keys listed in `Exclude`. */
77
110
  export type PropsOf<T, Exclude extends string = ''> = T extends React.ComponentType<infer P> ? Omit<P, Exclude> : any
78
111
 
112
+ /** A dictionary with string keys and homogeneous values of type `T`. Prefer over `Record<string, T>` when the key set is unknown at compile time. */
79
113
  export type Hashmap<T> = {
80
114
  [key: string]: T
81
115
  }
82
116
 
117
+ /** Unwraps the resolved value of a `Promise<U>`. Passes non-promise types through unchanged. */
83
118
  export type UnwrapPromise<T> = T extends Promise<infer U> ? U : T
84
119
 
120
+ /** Extracts the resolved return type of an async function. Returns `never` for non-async functions. */
85
121
  export type AsyncReturnType<T> = T extends (...args: any[]) => Promise<infer U> ? U : never
86
122
 
123
+ /**
124
+ * Extracts the `variants` prop type from a component that accepts `{ variants: V }`.
125
+ * Falls back to `string[]` when the inferred type is not a string or string array.
126
+ */
87
127
  export type VariantsOf<T> =T extends ((props: {variants: infer V}) => any) ?
88
128
  (V extends (string | string[]) ? V : (string[]))
89
129
 
90
130
  : (string[])
91
131
 
132
+ /** Strips `string` from a union, leaving only the non-string literal members. Useful for extracting enum-like members from a mixed union. */
92
133
  export type VariantList<T> = Exclude<T, string>
93
134
 
135
+ /** Unwraps the element type that a `React.Ref<U>` points to. */
94
136
  export type GetRefType<T> = T extends React.Ref<infer U> ? U : never
95
137
 
138
+ /**
139
+ * Returns a union of the keys of `T` whose value type extends `Filter`.
140
+ * Uses a sentinel string `'__never__'` internally to avoid distributing `never` in the union.
141
+ */
96
142
  export type FilterKeys<T, Filter = any> = Exclude<{
97
143
  [P in keyof T]: T[P] extends Filter ? P : '__never__'
98
144
  }[keyof T], '__never__'>
99
145
 
146
+ /** The tuple returned by `React.useState<T>()` — useful for passing state as a single prop. */
100
147
  export type ReactState<T = any> = [
101
148
  T,
102
149
  React.Dispatch<React.SetStateAction<T>>
103
150
  ]
104
151
 
152
+ /**
153
+ * Expands a state tuple into a props object with the value key and a `set<Name>` setter key.
154
+ * @example `ReactStateProps<'count', number>` → `{ count: number; setCount: Dispatch<...> }`
155
+ */
105
156
  export type ReactStateProps<Name extends string, T = any, State extends ReactState<T> = ReactState<T>> = {
106
157
  [P in Name as `set${Capitalize<Name>}`]: State[1]
107
158
  } & {
108
159
  [P in Name ]: State[0]
109
160
  }
110
161
 
162
+ /** Union of every ref shape React accepts — callback refs, `MutableRefObject`, `ForwardedRef`, and the legacy form. Use when a utility must accept any ref flavour. */
111
163
  export type AnyRef<T> = React.Ref<T> | React.MutableRefObject<T> | ((instance: T | null) => void) | null | React.ForwardedRef<T> | React.LegacyRef<T>
112
164
 
165
+ /** Produces a union of valid indices for a readonly tuple `T`. Excludes the `length` value itself. */
113
166
  export type Indices<T extends readonly any[]> = Exclude<Partial<T>['length'], T['length']>
114
167
 
168
+ /** Replaces the types of specific keys `Keys` in `Object` with `With`, leaving all other keys intact. */
115
169
  export type Replace<Object, Keys extends keyof Object, With = any> = Omit<Object, Keys> & {
116
170
  [P in Keys]: With
117
171
  }
118
172
 
173
+ /**
174
+ * Flexible predicate type used for filtering or matching.
175
+ * Accepts a plain string, a partial `RegExp` descriptor, or a two-argument predicate
176
+ * that receives the value/key and a type discriminant `T`.
177
+ */
119
178
  export type Matcher<T> = string | Partial<RegExp> | FunctionType<[valueOrKey: any, type: T], boolean>
120
179
 
180
+ /** Logger severity levels, including `'silent'` to suppress all output. */
121
181
  export type LogType = 'info' | 'debug' | 'warn' | 'error' | 'log' | 'silent'
122
182
 
183
+ /** Drops the first argument of a function and returns the remaining parameter types. */
123
184
  export type SecondToLastArguments<T extends AnyFunction> = T extends ((...args: [infer _, ...infer Rest]) => any) ? Rest : never
124
185
 
186
+ /** An array of `{ label, value }` pairs — the canonical shape for select/dropdown data sources. */
125
187
  export type Options<T> = { label: string; value: T }[]
126
188
 
189
+ /** A single entry from an `Options<T>` array. */
127
190
  export type Option<T> = Options<T>[number]
128
191
 
192
+ /** A label that can be a plain string or any React-renderable node. */
129
193
  export type Label = string | ReactNode
130
194
 
195
+ /** Union of all value types in `T`. Equivalent to `T[keyof T]`. */
131
196
  export type ValueOf<T> = T[keyof T]
132
197
 
198
+ /** Alias for `keyof T` — useful when you need to pass the key union as a generic argument. */
133
199
  export type Keyof<T> = keyof T
package/package.json.bak DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "name": "@codeleap/types",
3
- "version": "6.2.3",
4
- "main": "src/index.ts",
5
- "license": "UNLICENSED",
6
- "repository": {
7
- "url": "https://github.com/codeleap-uk/internal-libs-monorepo.git",
8
- "type": "git",
9
- "directory": "packages/types"
10
- },
11
- "devDependencies": {
12
- "@codeleap/config": "workspace:*",
13
- "ts-node-dev": "1.1.8"
14
- },
15
- "scripts": {
16
- "build": "echo 'No build needed'"
17
- },
18
- "peerDependencies": {
19
- "typescript": "5.5.2",
20
- "react": "19.1.0"
21
- }
22
- }