@stackone/utils 0.10.1 → 0.12.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.
- package/dist/edge/index.d.mts +145 -0
- package/dist/edge/index.mjs +29 -0
- package/dist/{index.d.mts → node/index.d.mts} +23 -19
- package/dist/{index.d.ts → node/index.d.ts} +24 -20
- package/dist/{index.js → node/index.js} +5 -5
- package/dist/node/index.mjs +29 -0
- package/package.json +18 -17
- package/dist/index.mjs +0 -29
|
@@ -0,0 +1,145 @@
|
|
|
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/documents/fileFormats.d.ts
|
|
77
|
+
|
|
78
|
+
declare const getDocumentFileFormatFromExtension: (fileExtension: unknown) => string | undefined;
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/shared/exponentialBackoff.d.ts
|
|
81
|
+
declare const exponentialBackoffInMS: (retryCount: number, baseRetryDelayInMS?: number, jitterFactor?: number) => number;
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/shared/ipAddr.d.ts
|
|
84
|
+
declare const isValidIp: (ip: string) => boolean;
|
|
85
|
+
declare const isValidIpRange: (pattern: string) => boolean;
|
|
86
|
+
declare const isValidIpRanges: (patterns: string[]) => boolean;
|
|
87
|
+
declare const isIpInRanges: (ip: string, patterns: string[]) => boolean;
|
|
88
|
+
declare const isIpInRange: (ip: string, pattern: string) => boolean;
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/shared/parsers.d.ts
|
|
91
|
+
declare const safeParseToString: ({
|
|
92
|
+
value
|
|
93
|
+
}: {
|
|
94
|
+
value: unknown;
|
|
95
|
+
}) => string | null;
|
|
96
|
+
declare const safeParseToNumber: ({
|
|
97
|
+
value
|
|
98
|
+
}: {
|
|
99
|
+
value: unknown;
|
|
100
|
+
}) => number | null;
|
|
101
|
+
declare const safeParseToBoolean: ({
|
|
102
|
+
value
|
|
103
|
+
}: {
|
|
104
|
+
value: unknown;
|
|
105
|
+
}) => boolean | null;
|
|
106
|
+
declare const safeParseToDateTime: ({
|
|
107
|
+
value,
|
|
108
|
+
format
|
|
109
|
+
}: {
|
|
110
|
+
value: unknown;
|
|
111
|
+
format?: string;
|
|
112
|
+
}) => Date | null;
|
|
113
|
+
declare const safeParseToDateTimeString: ({
|
|
114
|
+
value,
|
|
115
|
+
format
|
|
116
|
+
}: {
|
|
117
|
+
value: unknown;
|
|
118
|
+
format?: string;
|
|
119
|
+
}) => string | null;
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/shared/timeouts.d.ts
|
|
122
|
+
declare const delay: (ms: number) => Promise<unknown>;
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/shared/typeguards.d.ts
|
|
125
|
+
declare const notMissing: <T>(value: T | null | undefined) => value is T;
|
|
126
|
+
declare const isMissing: <T>(value: T | null | undefined) => value is null | undefined;
|
|
127
|
+
declare const isString: (value: unknown) => value is string;
|
|
128
|
+
declare const isNumber: (value: unknown) => value is number;
|
|
129
|
+
declare const isBoolean: (value: unknown) => value is boolean;
|
|
130
|
+
declare const isDate: (value: unknown) => value is Date;
|
|
131
|
+
declare const isObject: (value: unknown) => value is Record<string, unknown>;
|
|
132
|
+
declare const isFunction: (value: unknown) => value is (...args: unknown[]) => unknown;
|
|
133
|
+
declare const isFutureUnixTimestamp: (value: unknown) => boolean;
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/shared/zod.d.ts
|
|
136
|
+
declare const zStrictObject: <T extends z.ZodRawShape>(shape: T) => z.ZodObject<{ -readonly [P in keyof T]: T[P] }, z.core.$strict>;
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region src/edge/hashContent.d.ts
|
|
139
|
+
declare const getContentHash: (content: unknown) => string;
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/edge/uuids.d.ts
|
|
142
|
+
declare const isValidUUID: (uuid: string) => boolean;
|
|
143
|
+
declare const generateRequestId: (randomUUIDGenerator?: () => string) => string;
|
|
144
|
+
//#endregion
|
|
145
|
+
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, getDocumentFileFormatFromExtension, isBoolean, isDate, isFunction, isFutureUnixTimestamp, isIpInRange, isIpInRanges, isMissing, isNumber, isObject, isString, isValidIp, isValidIpRange, isValidIpRanges, isValidUUID, notMissing, safeParseToBoolean, safeParseToDateTime, safeParseToDateTimeString, safeParseToNumber, safeParseToString, z, zStrictObject };
|