@stackone/utils 0.10.1 → 0.11.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,141 @@
1
+ import { ZodType, z } from "zod/v4";
2
+
3
+ //#region src/shared/base64.d.ts
4
+ declare function encodeToBase64(data: string): string;
5
+ declare function decodeFromBase64(encodedData: string): string;
6
+ //#endregion
7
+ //#region src/shared/countries/types.d.ts
8
+
9
+ type ISO31662SubDivisionCodeNamePairs = {
10
+ [subDivisionCode: string]: string;
11
+ };
12
+ //#endregion
13
+ //#region src/shared/countries/countriesGetters.d.ts
14
+ declare const getCountryAlpha2CodeByAlpha2Code: (alpha2Code: string) => string | undefined;
15
+ declare const getCountryAlpha3CodeByAlpha3Code: (alpha3Code: string) => string | undefined;
16
+ declare const getCountryCodeByCountryCode: (countryCode: string) => string | undefined;
17
+ declare const getCountryNameByCountryName: (countryName: string) => string | undefined;
18
+ declare const getCountryNameByAlpha3Code: (alpha3Code: string) => string | undefined;
19
+ declare const getCountryNameByAlpha2Code: (alpha2Code: string) => string | undefined;
20
+ declare const getCountryNameByCountryCode: (countryCode: string) => string | undefined;
21
+ declare const getCountryAlpha3CodeByAlpha2Code: (alpha2Code: string) => string | undefined;
22
+ declare const getCountryAlpha3CodeByCountryName: (countryName: string) => string | undefined;
23
+ declare const getCountryAlpha3CodeByCountryCode: (countryCode: string) => string | undefined;
24
+ declare const getCountryAlpha2CodeByAlpha3Code: (alpha3Code: string) => string | undefined;
25
+ declare const getCountryAlpha2CodeByCountryName: (countryName: string) => string | undefined;
26
+ declare const getCountryAlpha2CodeByCountryCode: (countryCode: string) => string | undefined;
27
+ declare const getCountryCodeByAlpha2Code: (alpha2Code: string) => string | undefined;
28
+ declare const getCountryCodeByAlpha3Code: (alpha3Code: string) => string | undefined;
29
+ declare const getCountryCodeByCountryName: (countryName: string) => string | undefined;
30
+ declare const getCountrySubDivisionsByAlpha2Code: (alpha2Code: string) => ISO31662SubDivisionCodeNamePairs | undefined;
31
+ declare const getCountrySubDivisionByAlpha2CodeAndName: (alpha2Code: string, subDivisionName: string) => string | undefined;
32
+ declare const getCountrySubDivisionNameBySubDivisionCode: (subDivisionCode: string) => string | undefined;
33
+ declare const getCountrySubDivisionCodeBySubDivisionName: (subDivisionName: string) => string | undefined;
34
+ declare const getCountryAlpha2CodeByCitizenship: (citizenship: string) => string | undefined;
35
+ //#endregion
36
+ //#region src/shared/dataStructures/normalizedKeyMap.d.ts
37
+ declare class NormalizedKeyMap<V> extends Map<string, any> {
38
+ #private;
39
+ set(key: string, value: V): this;
40
+ get(key: string): V | undefined;
41
+ has(key: string): boolean;
42
+ delete(key: string): boolean;
43
+ }
44
+ //#endregion
45
+ //#region src/shared/dates.d.ts
46
+ type InputDate = Date | string | null;
47
+ declare const calculateNextAnniversary: ({
48
+ initialDate,
49
+ format
50
+ }: {
51
+ initialDate?: InputDate;
52
+ format?: string;
53
+ }) => Date | null;
54
+ declare const calculateYearsElapsed: ({
55
+ startDate,
56
+ endDate,
57
+ format
58
+ }: {
59
+ startDate?: InputDate;
60
+ endDate?: InputDate;
61
+ format?: string;
62
+ }) => number | null;
63
+ declare const dateHasPassed: ({
64
+ date,
65
+ yearsToAdd,
66
+ format
67
+ }: {
68
+ date?: InputDate;
69
+ yearsToAdd?: number;
70
+ format?: string;
71
+ }) => boolean;
72
+ //#endregion
73
+ //#region src/shared/deepCopy.d.ts
74
+ declare const deepCopy: <T>(obj: T, visited?: WeakMap<object, any>) => T;
75
+ //#endregion
76
+ //#region src/shared/exponentialBackoff.d.ts
77
+ declare const exponentialBackoffInMS: (retryCount: number, baseRetryDelayInMS?: number, jitterFactor?: number) => number;
78
+ //#endregion
79
+ //#region src/shared/ipAddr.d.ts
80
+ declare const isValidIp: (ip: string) => boolean;
81
+ declare const isValidIpRange: (pattern: string) => boolean;
82
+ declare const isValidIpRanges: (patterns: string[]) => boolean;
83
+ declare const isIpInRanges: (ip: string, patterns: string[]) => boolean;
84
+ declare const isIpInRange: (ip: string, pattern: string) => boolean;
85
+ //#endregion
86
+ //#region src/shared/parsers.d.ts
87
+ declare const safeParseToString: ({
88
+ value
89
+ }: {
90
+ value: unknown;
91
+ }) => string | null;
92
+ declare const safeParseToNumber: ({
93
+ value
94
+ }: {
95
+ value: unknown;
96
+ }) => number | null;
97
+ declare const safeParseToBoolean: ({
98
+ value
99
+ }: {
100
+ value: unknown;
101
+ }) => boolean | null;
102
+ declare const safeParseToDateTime: ({
103
+ value,
104
+ format
105
+ }: {
106
+ value: unknown;
107
+ format?: string;
108
+ }) => Date | null;
109
+ declare const safeParseToDateTimeString: ({
110
+ value,
111
+ format
112
+ }: {
113
+ value: unknown;
114
+ format?: string;
115
+ }) => string | null;
116
+ //#endregion
117
+ //#region src/shared/timeouts.d.ts
118
+ declare const delay: (ms: number) => Promise<unknown>;
119
+ //#endregion
120
+ //#region src/shared/typeguards.d.ts
121
+ declare const notMissing: <T>(value: T | null | undefined) => value is T;
122
+ declare const isMissing: <T>(value: T | null | undefined) => value is null | undefined;
123
+ declare const isString: (value: unknown) => value is string;
124
+ declare const isNumber: (value: unknown) => value is number;
125
+ declare const isBoolean: (value: unknown) => value is boolean;
126
+ declare const isDate: (value: unknown) => value is Date;
127
+ declare const isObject: (value: unknown) => value is Record<string, unknown>;
128
+ declare const isFunction: (value: unknown) => value is (...args: unknown[]) => unknown;
129
+ declare const isFutureUnixTimestamp: (value: unknown) => boolean;
130
+ //#endregion
131
+ //#region src/shared/zod.d.ts
132
+ declare const zStrictObject: <T extends z.ZodRawShape>(shape: T) => z.ZodObject<{ -readonly [P in keyof T]: T[P] }, z.core.$strict>;
133
+ //#endregion
134
+ //#region src/edge/hashContent.d.ts
135
+ declare const getContentHash: (content: unknown) => string;
136
+ //#endregion
137
+ //#region src/edge/uuids.d.ts
138
+ declare const isValidUUID: (uuid: string) => boolean;
139
+ declare const generateRequestId: (randomUUIDGenerator?: () => string) => string;
140
+ //#endregion
141
+ export { NormalizedKeyMap, ZodType, calculateNextAnniversary, calculateYearsElapsed, dateHasPassed, decodeFromBase64, deepCopy, delay, encodeToBase64, exponentialBackoffInMS, generateRequestId, getContentHash, getCountryAlpha2CodeByAlpha2Code, getCountryAlpha2CodeByAlpha3Code, getCountryAlpha2CodeByCitizenship, getCountryAlpha2CodeByCountryCode, getCountryAlpha2CodeByCountryName, getCountryAlpha3CodeByAlpha2Code, getCountryAlpha3CodeByAlpha3Code, getCountryAlpha3CodeByCountryCode, getCountryAlpha3CodeByCountryName, getCountryCodeByAlpha2Code, getCountryCodeByAlpha3Code, getCountryCodeByCountryCode, getCountryCodeByCountryName, getCountryNameByAlpha2Code, getCountryNameByAlpha3Code, getCountryNameByCountryCode, getCountryNameByCountryName, getCountrySubDivisionByAlpha2CodeAndName, getCountrySubDivisionCodeBySubDivisionName, getCountrySubDivisionNameBySubDivisionCode, getCountrySubDivisionsByAlpha2Code, isBoolean, isDate, isFunction, isFutureUnixTimestamp, isIpInRange, isIpInRanges, isMissing, isNumber, isObject, isString, isValidIp, isValidIpRange, isValidIpRanges, isValidUUID, notMissing, safeParseToBoolean, safeParseToDateTime, safeParseToDateTimeString, safeParseToNumber, safeParseToString, z, zStrictObject };