@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
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { randomUUID } from "crypto";
|
|
2
2
|
import { ZodType, z } from "zod/v4";
|
|
3
3
|
|
|
4
|
-
//#region src/base64.d.ts
|
|
4
|
+
//#region src/shared/base64.d.ts
|
|
5
5
|
declare function encodeToBase64(data: string): string;
|
|
6
6
|
declare function decodeFromBase64(encodedData: string): string;
|
|
7
7
|
//#endregion
|
|
8
|
-
//#region src/countries/types.d.ts
|
|
8
|
+
//#region src/shared/countries/types.d.ts
|
|
9
9
|
|
|
10
10
|
type ISO31662SubDivisionCodeNamePairs = {
|
|
11
11
|
[subDivisionCode: string]: string;
|
|
12
12
|
};
|
|
13
13
|
//#endregion
|
|
14
|
-
//#region src/countries/countriesGetters.d.ts
|
|
14
|
+
//#region src/shared/countries/countriesGetters.d.ts
|
|
15
15
|
declare const getCountryAlpha2CodeByAlpha2Code: (alpha2Code: string) => string | undefined;
|
|
16
16
|
declare const getCountryAlpha3CodeByAlpha3Code: (alpha3Code: string) => string | undefined;
|
|
17
17
|
declare const getCountryCodeByCountryCode: (countryCode: string) => string | undefined;
|
|
@@ -34,7 +34,7 @@ declare const getCountrySubDivisionNameBySubDivisionCode: (subDivisionCode: stri
|
|
|
34
34
|
declare const getCountrySubDivisionCodeBySubDivisionName: (subDivisionName: string) => string | undefined;
|
|
35
35
|
declare const getCountryAlpha2CodeByCitizenship: (citizenship: string) => string | undefined;
|
|
36
36
|
//#endregion
|
|
37
|
-
//#region src/dataStructures/normalizedKeyMap.d.ts
|
|
37
|
+
//#region src/shared/dataStructures/normalizedKeyMap.d.ts
|
|
38
38
|
declare class NormalizedKeyMap<V> extends Map<string, any> {
|
|
39
39
|
#private;
|
|
40
40
|
set(key: string, value: V): this;
|
|
@@ -43,7 +43,7 @@ declare class NormalizedKeyMap<V> extends Map<string, any> {
|
|
|
43
43
|
delete(key: string): boolean;
|
|
44
44
|
}
|
|
45
45
|
//#endregion
|
|
46
|
-
//#region src/dates.d.ts
|
|
46
|
+
//#region src/shared/dates.d.ts
|
|
47
47
|
type InputDate = Date | string | null;
|
|
48
48
|
declare const calculateNextAnniversary: ({
|
|
49
49
|
initialDate,
|
|
@@ -71,23 +71,24 @@ declare const dateHasPassed: ({
|
|
|
71
71
|
format?: string;
|
|
72
72
|
}) => boolean;
|
|
73
73
|
//#endregion
|
|
74
|
-
//#region src/deepCopy.d.ts
|
|
74
|
+
//#region src/shared/deepCopy.d.ts
|
|
75
75
|
declare const deepCopy: <T>(obj: T, visited?: WeakMap<object, any>) => T;
|
|
76
76
|
//#endregion
|
|
77
|
-
//#region src/
|
|
78
|
-
|
|
77
|
+
//#region src/shared/documents/fileFormats.d.ts
|
|
78
|
+
|
|
79
|
+
declare const getDocumentFileFormatFromExtension: (fileExtension: unknown) => string | undefined;
|
|
79
80
|
//#endregion
|
|
80
|
-
//#region src/
|
|
81
|
-
declare const
|
|
81
|
+
//#region src/shared/exponentialBackoff.d.ts
|
|
82
|
+
declare const exponentialBackoffInMS: (retryCount: number, baseRetryDelayInMS?: number, jitterFactor?: number) => number;
|
|
82
83
|
//#endregion
|
|
83
|
-
//#region src/ipAddr.d.ts
|
|
84
|
+
//#region src/shared/ipAddr.d.ts
|
|
84
85
|
declare const isValidIp: (ip: string) => boolean;
|
|
85
86
|
declare const isValidIpRange: (pattern: string) => boolean;
|
|
86
87
|
declare const isValidIpRanges: (patterns: string[]) => boolean;
|
|
87
88
|
declare const isIpInRanges: (ip: string, patterns: string[]) => boolean;
|
|
88
89
|
declare const isIpInRange: (ip: string, pattern: string) => boolean;
|
|
89
90
|
//#endregion
|
|
90
|
-
//#region src/parsers.d.ts
|
|
91
|
+
//#region src/shared/parsers.d.ts
|
|
91
92
|
declare const safeParseToString: ({
|
|
92
93
|
value
|
|
93
94
|
}: {
|
|
@@ -118,10 +119,10 @@ declare const safeParseToDateTimeString: ({
|
|
|
118
119
|
format?: string;
|
|
119
120
|
}) => string | null;
|
|
120
121
|
//#endregion
|
|
121
|
-
//#region src/timeouts.d.ts
|
|
122
|
+
//#region src/shared/timeouts.d.ts
|
|
122
123
|
declare const delay: (ms: number) => Promise<unknown>;
|
|
123
124
|
//#endregion
|
|
124
|
-
//#region src/typeguards.d.ts
|
|
125
|
+
//#region src/shared/typeguards.d.ts
|
|
125
126
|
declare const notMissing: <T>(value: T | null | undefined) => value is T;
|
|
126
127
|
declare const isMissing: <T>(value: T | null | undefined) => value is null | undefined;
|
|
127
128
|
declare const isString: (value: unknown) => value is string;
|
|
@@ -132,11 +133,14 @@ declare const isObject: (value: unknown) => value is Record<string, unknown>;
|
|
|
132
133
|
declare const isFunction: (value: unknown) => value is (...args: unknown[]) => unknown;
|
|
133
134
|
declare const isFutureUnixTimestamp: (value: unknown) => boolean;
|
|
134
135
|
//#endregion
|
|
135
|
-
//#region src/
|
|
136
|
+
//#region src/shared/zod.d.ts
|
|
137
|
+
declare const zStrictObject: <T extends z.ZodRawShape>(shape: T) => z.ZodObject<{ -readonly [P in keyof T]: T[P] }, z.core.$strict>;
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/node/hashContent.d.ts
|
|
140
|
+
declare const getContentHash: (content: unknown) => string;
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/node/uuids.d.ts
|
|
136
143
|
declare const isValidUUID: (uuid: string) => boolean;
|
|
137
144
|
declare const generateRequestId: (randomUUIDGenerator?: typeof randomUUID) => string;
|
|
138
145
|
//#endregion
|
|
139
|
-
|
|
140
|
-
declare const zStrictObject: <T extends z.ZodRawShape>(shape: T) => z.ZodObject<{ -readonly [P in keyof T]: T[P] }, z.core.$strict>;
|
|
141
|
-
//#endregion
|
|
142
|
-
export { NormalizedKeyMap, type 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 };
|
|
146
|
+
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 };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { randomUUID } from "crypto";
|
|
2
1
|
import { ZodType, z } from "zod/v4";
|
|
2
|
+
import { randomUUID } from "crypto";
|
|
3
3
|
|
|
4
|
-
//#region src/base64.d.ts
|
|
4
|
+
//#region src/shared/base64.d.ts
|
|
5
5
|
declare function encodeToBase64(data: string): string;
|
|
6
6
|
declare function decodeFromBase64(encodedData: string): string;
|
|
7
7
|
//#endregion
|
|
8
|
-
//#region src/countries/types.d.ts
|
|
8
|
+
//#region src/shared/countries/types.d.ts
|
|
9
9
|
|
|
10
10
|
type ISO31662SubDivisionCodeNamePairs = {
|
|
11
11
|
[subDivisionCode: string]: string;
|
|
12
12
|
};
|
|
13
13
|
//#endregion
|
|
14
|
-
//#region src/countries/countriesGetters.d.ts
|
|
14
|
+
//#region src/shared/countries/countriesGetters.d.ts
|
|
15
15
|
declare const getCountryAlpha2CodeByAlpha2Code: (alpha2Code: string) => string | undefined;
|
|
16
16
|
declare const getCountryAlpha3CodeByAlpha3Code: (alpha3Code: string) => string | undefined;
|
|
17
17
|
declare const getCountryCodeByCountryCode: (countryCode: string) => string | undefined;
|
|
@@ -34,7 +34,7 @@ declare const getCountrySubDivisionNameBySubDivisionCode: (subDivisionCode: stri
|
|
|
34
34
|
declare const getCountrySubDivisionCodeBySubDivisionName: (subDivisionName: string) => string | undefined;
|
|
35
35
|
declare const getCountryAlpha2CodeByCitizenship: (citizenship: string) => string | undefined;
|
|
36
36
|
//#endregion
|
|
37
|
-
//#region src/dataStructures/normalizedKeyMap.d.ts
|
|
37
|
+
//#region src/shared/dataStructures/normalizedKeyMap.d.ts
|
|
38
38
|
declare class NormalizedKeyMap<V> extends Map<string, any> {
|
|
39
39
|
#private;
|
|
40
40
|
set(key: string, value: V): this;
|
|
@@ -43,7 +43,7 @@ declare class NormalizedKeyMap<V> extends Map<string, any> {
|
|
|
43
43
|
delete(key: string): boolean;
|
|
44
44
|
}
|
|
45
45
|
//#endregion
|
|
46
|
-
//#region src/dates.d.ts
|
|
46
|
+
//#region src/shared/dates.d.ts
|
|
47
47
|
type InputDate = Date | string | null;
|
|
48
48
|
declare const calculateNextAnniversary: ({
|
|
49
49
|
initialDate,
|
|
@@ -71,23 +71,24 @@ declare const dateHasPassed: ({
|
|
|
71
71
|
format?: string;
|
|
72
72
|
}) => boolean;
|
|
73
73
|
//#endregion
|
|
74
|
-
//#region src/deepCopy.d.ts
|
|
74
|
+
//#region src/shared/deepCopy.d.ts
|
|
75
75
|
declare const deepCopy: <T>(obj: T, visited?: WeakMap<object, any>) => T;
|
|
76
76
|
//#endregion
|
|
77
|
-
//#region src/
|
|
78
|
-
|
|
77
|
+
//#region src/shared/documents/fileFormats.d.ts
|
|
78
|
+
|
|
79
|
+
declare const getDocumentFileFormatFromExtension: (fileExtension: unknown) => string | undefined;
|
|
79
80
|
//#endregion
|
|
80
|
-
//#region src/
|
|
81
|
-
declare const
|
|
81
|
+
//#region src/shared/exponentialBackoff.d.ts
|
|
82
|
+
declare const exponentialBackoffInMS: (retryCount: number, baseRetryDelayInMS?: number, jitterFactor?: number) => number;
|
|
82
83
|
//#endregion
|
|
83
|
-
//#region src/ipAddr.d.ts
|
|
84
|
+
//#region src/shared/ipAddr.d.ts
|
|
84
85
|
declare const isValidIp: (ip: string) => boolean;
|
|
85
86
|
declare const isValidIpRange: (pattern: string) => boolean;
|
|
86
87
|
declare const isValidIpRanges: (patterns: string[]) => boolean;
|
|
87
88
|
declare const isIpInRanges: (ip: string, patterns: string[]) => boolean;
|
|
88
89
|
declare const isIpInRange: (ip: string, pattern: string) => boolean;
|
|
89
90
|
//#endregion
|
|
90
|
-
//#region src/parsers.d.ts
|
|
91
|
+
//#region src/shared/parsers.d.ts
|
|
91
92
|
declare const safeParseToString: ({
|
|
92
93
|
value
|
|
93
94
|
}: {
|
|
@@ -118,10 +119,10 @@ declare const safeParseToDateTimeString: ({
|
|
|
118
119
|
format?: string;
|
|
119
120
|
}) => string | null;
|
|
120
121
|
//#endregion
|
|
121
|
-
//#region src/timeouts.d.ts
|
|
122
|
+
//#region src/shared/timeouts.d.ts
|
|
122
123
|
declare const delay: (ms: number) => Promise<unknown>;
|
|
123
124
|
//#endregion
|
|
124
|
-
//#region src/typeguards.d.ts
|
|
125
|
+
//#region src/shared/typeguards.d.ts
|
|
125
126
|
declare const notMissing: <T>(value: T | null | undefined) => value is T;
|
|
126
127
|
declare const isMissing: <T>(value: T | null | undefined) => value is null | undefined;
|
|
127
128
|
declare const isString: (value: unknown) => value is string;
|
|
@@ -132,11 +133,14 @@ declare const isObject: (value: unknown) => value is Record<string, unknown>;
|
|
|
132
133
|
declare const isFunction: (value: unknown) => value is (...args: unknown[]) => unknown;
|
|
133
134
|
declare const isFutureUnixTimestamp: (value: unknown) => boolean;
|
|
134
135
|
//#endregion
|
|
135
|
-
//#region src/
|
|
136
|
+
//#region src/shared/zod.d.ts
|
|
137
|
+
declare const zStrictObject: <T extends z.ZodRawShape>(shape: T) => z.ZodObject<{ -readonly [P in keyof T]: T[P] }, z.core.$strict>;
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/node/hashContent.d.ts
|
|
140
|
+
declare const getContentHash: (content: unknown) => string;
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/node/uuids.d.ts
|
|
136
143
|
declare const isValidUUID: (uuid: string) => boolean;
|
|
137
144
|
declare const generateRequestId: (randomUUIDGenerator?: typeof randomUUID) => string;
|
|
138
145
|
//#endregion
|
|
139
|
-
|
|
140
|
-
declare const zStrictObject: <T extends z.ZodRawShape>(shape: T) => z.ZodObject<{ -readonly [P in keyof T]: T[P] }, z.core.$strict>;
|
|
141
|
-
//#endregion
|
|
142
|
-
export { NormalizedKeyMap, type 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 };
|
|
146
|
+
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 };
|