@esposter/shared 3.2.0 → 3.4.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/index.d.ts +14 -5
- package/dist/index.js +26 -13
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Result, ResultAsync } from "neverthrow";
|
|
|
3
3
|
import { HTMLElement } from "node-html-parser";
|
|
4
4
|
import baseSanitizeHtml from "sanitize-html";
|
|
5
5
|
//#region src/test/constants.d.ts
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const ALL_SPECIAL_VALUES: {
|
|
7
7
|
isPlainObject: boolean;
|
|
8
8
|
value: unknown;
|
|
9
9
|
}[];
|
|
@@ -58,6 +58,7 @@ export interface MaybeReactive {
|
|
|
58
58
|
export declare const RoutePath: {
|
|
59
59
|
readonly About: "/about";
|
|
60
60
|
readonly Achievements: "/achievements";
|
|
61
|
+
readonly AgentConsole: "/agent-console";
|
|
61
62
|
readonly Anime: "/anime";
|
|
62
63
|
readonly Calls: (id: string) => string;
|
|
63
64
|
readonly CallsIndex: "/calls";
|
|
@@ -1970,19 +1971,19 @@ export declare const KIBIBYTE: number;
|
|
|
1970
1971
|
export declare const GIBIBYTE: number;
|
|
1971
1972
|
//#endregion
|
|
1972
1973
|
//#region src/services/error/getResult.d.ts
|
|
1973
|
-
export declare const getResult: <T>(
|
|
1974
|
+
export declare const getResult: <T>(callback: () => T) => Result<T, Error>;
|
|
1974
1975
|
//#endregion
|
|
1975
1976
|
//#region src/services/error/getResultAsync.d.ts
|
|
1976
|
-
export declare const getResultAsync: <T>(
|
|
1977
|
+
export declare const getResultAsync: <T>(callback: () => Promise<T>) => ResultAsync<T, Error>;
|
|
1977
1978
|
//#endregion
|
|
1978
1979
|
//#region src/services/error/toAppError.d.ts
|
|
1979
1980
|
export declare const toAppError: (error: unknown) => Error;
|
|
1980
1981
|
//#endregion
|
|
1981
1982
|
//#region src/services/error/withFinalizer.d.ts
|
|
1982
|
-
export declare const withFinalizer: <T>(
|
|
1983
|
+
export declare const withFinalizer: <T>(callback: () => T, finalizer?: () => void) => T;
|
|
1983
1984
|
//#endregion
|
|
1984
1985
|
//#region src/services/error/withFinalizerAsync.d.ts
|
|
1985
|
-
export declare const withFinalizerAsync: <T>(
|
|
1986
|
+
export declare const withFinalizerAsync: <T>(callback: () => Promisable<T>, finalizer?: () => Promisable<void>) => Promise<T>;
|
|
1986
1987
|
//#endregion
|
|
1987
1988
|
//#region src/services/message/constants.d.ts
|
|
1988
1989
|
export declare const MENTION_ID_ATTRIBUTE = "data-id";
|
|
@@ -2020,6 +2021,14 @@ export declare const createNormalizedStringSchema: (maxLength: number, schema?:
|
|
|
2020
2021
|
//#region src/services/zod/createUniqueArraySchema.d.ts
|
|
2021
2022
|
export declare const createUniqueArraySchema: CreateUniqueArraySchema;
|
|
2022
2023
|
//#endregion
|
|
2024
|
+
//#region src/services/zstd/constants.d.ts
|
|
2025
|
+
export declare const DEFAULT_COMPRESSION_LEVEL = 12;
|
|
2026
|
+
export declare const MIN_WINDOW_LOG = 10;
|
|
2027
|
+
export declare const MAX_WINDOW_LOG = 27;
|
|
2028
|
+
//#endregion
|
|
2029
|
+
//#region src/services/zstd/getWindowLog.d.ts
|
|
2030
|
+
export declare const getWindowLog: (dictionaryByteCount: number, inputByteCount: number) => number;
|
|
2031
|
+
//#endregion
|
|
2023
2032
|
//#region src/util/array/chunk.d.ts
|
|
2024
2033
|
export declare const chunk: <T>(array: T[], size: number) => T[][];
|
|
2025
2034
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import baseSanitizeHtml from "sanitize-html";
|
|
|
6
6
|
const noop = () => {};
|
|
7
7
|
//#endregion
|
|
8
8
|
//#region src/test/constants.ts
|
|
9
|
-
const
|
|
9
|
+
const ALL_SPECIAL_VALUES = [
|
|
10
10
|
{
|
|
11
11
|
isPlainObject: true,
|
|
12
12
|
value: {}
|
|
@@ -110,6 +110,7 @@ const GIBIBYTE = KIBIBYTE ** 2 * KIBIBYTE;
|
|
|
110
110
|
const RoutePath = {
|
|
111
111
|
About: "/about",
|
|
112
112
|
Achievements: "/achievements",
|
|
113
|
+
AgentConsole: "/agent-console",
|
|
113
114
|
Anime: "/anime",
|
|
114
115
|
Calls: (id) => `/calls/${id}`,
|
|
115
116
|
CallsIndex: "/calls",
|
|
@@ -198,33 +199,37 @@ const toAppError = (error) => {
|
|
|
198
199
|
};
|
|
199
200
|
//#endregion
|
|
200
201
|
//#region src/services/error/getResult.ts
|
|
201
|
-
const getResult = (
|
|
202
|
+
const getResult = (callback) => fromThrowable(callback, toAppError)();
|
|
202
203
|
//#endregion
|
|
203
204
|
//#region src/services/error/getResultAsync.ts
|
|
204
|
-
const getResultAsync = (
|
|
205
|
+
const getResultAsync = (callback) => ResultAsync.fromThrowable(callback, toAppError)();
|
|
205
206
|
//#endregion
|
|
206
207
|
//#region src/services/error/withFinalizer.ts
|
|
207
|
-
const withFinalizer = (
|
|
208
|
-
const
|
|
209
|
-
(finalizer
|
|
210
|
-
|
|
208
|
+
const withFinalizer = (callback, finalizer) => {
|
|
209
|
+
const callbackResult = getResult(callback);
|
|
210
|
+
if (finalizer) getResult(finalizer).match(noop, (error) => {
|
|
211
|
+
callbackResult.match(() => {
|
|
212
|
+
throw error;
|
|
213
|
+
}, () => {
|
|
214
|
+
console.error(error);
|
|
215
|
+
});
|
|
211
216
|
});
|
|
212
|
-
return
|
|
217
|
+
return callbackResult.match((value) => value, (error) => {
|
|
213
218
|
throw error;
|
|
214
219
|
});
|
|
215
220
|
};
|
|
216
221
|
//#endregion
|
|
217
222
|
//#region src/services/error/withFinalizerAsync.ts
|
|
218
|
-
const withFinalizerAsync = async (
|
|
219
|
-
const
|
|
223
|
+
const withFinalizerAsync = async (callback, finalizer) => {
|
|
224
|
+
const callbackResult = await getResultAsync(async () => callback());
|
|
220
225
|
if (finalizer) await getResultAsync(async () => finalizer()).match(noop, (error) => {
|
|
221
|
-
|
|
226
|
+
callbackResult.match(() => {
|
|
222
227
|
throw error;
|
|
223
228
|
}, () => {
|
|
224
229
|
console.error(error);
|
|
225
230
|
});
|
|
226
231
|
});
|
|
227
|
-
return
|
|
232
|
+
return callbackResult.match((value) => value, (error) => {
|
|
228
233
|
throw error;
|
|
229
234
|
});
|
|
230
235
|
};
|
|
@@ -333,6 +338,14 @@ const createNormalizedStringSchema = (maxLength, schema = z.string()) => schema.
|
|
|
333
338
|
//#region src/services/zod/createUniqueArraySchema.ts
|
|
334
339
|
const createUniqueArraySchema = (schema, key) => schema.array().refine((array) => new Set(key === void 0 ? array : array.map((item) => item[key])).size === array.length, "Array items must be unique");
|
|
335
340
|
//#endregion
|
|
341
|
+
//#region src/services/zstd/constants.ts
|
|
342
|
+
const DEFAULT_COMPRESSION_LEVEL = 12;
|
|
343
|
+
const MIN_WINDOW_LOG = 10;
|
|
344
|
+
const MAX_WINDOW_LOG = 27;
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region src/services/zstd/getWindowLog.ts
|
|
347
|
+
const getWindowLog = (dictionaryByteCount, inputByteCount) => Math.min(27, Math.max(10, Math.ceil(Math.log2(dictionaryByteCount + inputByteCount + 1))));
|
|
348
|
+
//#endregion
|
|
336
349
|
//#region src/util/array/chunk.ts
|
|
337
350
|
const chunk = (array, size) => {
|
|
338
351
|
const chunks = [];
|
|
@@ -502,4 +515,4 @@ const exhaustiveGuard = (value) => {
|
|
|
502
515
|
//#region src/util/id/uuid/constants.ts
|
|
503
516
|
const UUIDV4_REGEX = /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/iu;
|
|
504
517
|
//#endregion
|
|
505
|
-
export {
|
|
518
|
+
export { ALL_SPECIAL_VALUES, CUSTOM_EMOJI_ID_ATTRIBUTE, CUSTOM_EMOJI_NAME_ATTRIBUTE, DEFAULT_COMPRESSION_LEVEL, ForbiddenError, GIBIBYTE, ID_SEPARATOR, InvalidOperationError, ItemMetadata, KIBIBYTE, MAX_READ_LIMIT, MAX_WINDOW_LOG, MENTION_EVERYONE_ID, MENTION_HERE_ID, MENTION_ID_ATTRIBUTE, MENTION_ITEM_TYPE_ATTRIBUTE, MENTION_LABEL_ATTRIBUTE, MENTION_SELECTOR, MENTION_TYPE, MENTION_TYPE_ATTRIBUTE, MIN_WINDOW_LOG, MentionType, NotFoundError, NotInitializedError, Operation, RoutePath, SITE_NAME, Serializable, UUIDV4_REGEX, WordFilteredError, applyItemMetadataMixin, capitalize, checkIsPlainObject, checkIsServer, chunk, chunkBySerializedSize, createItemEntityTypeSchema, createNormalizedStringSchema, createUniqueArraySchema, css, encodeUrlSubDelimiters, exhaustiveGuard, getDecodedUriComponent, getEndOfDay, getMentions, getOrCreate, getPropertyNames, getRawData, getResult, getResultAsync, getWindowLog, getZonedDateTime, hrtime, html, jsonDateParse, mergeObjectsStrict, noop, normalizeString, now, sanitizeHtml, sanitizeTextHtml, settleAll, sleep, streamToText, takeOne, toAppError, toKebabCase, toRawDeep, truncate, uncapitalize, withFinalizer, withFinalizerAsync };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esposter/shared",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "A library that contains shared typescript code.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"error-handling",
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@arethetypeswrong/core": "^0.18.5",
|
|
58
58
|
"@azure/data-tables": "^13.3.2",
|
|
59
|
-
"@esposter/configuration": "3.
|
|
60
|
-
"@types/node": "^26.6.
|
|
59
|
+
"@esposter/configuration": "3.4.0",
|
|
60
|
+
"@types/node": "^26.6.3",
|
|
61
61
|
"@types/sanitize-html": "^2.16.1",
|
|
62
62
|
"publint": "^0.3.24",
|
|
63
63
|
"tsdown": "^0.23.0",
|
|
64
64
|
"type-fest": "^5.10.0",
|
|
65
|
-
"vitest": "^5.0.
|
|
65
|
+
"vitest": "^5.0.2",
|
|
66
66
|
"vue": "^3.5.43"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"inlinedDependencies": {
|
|
72
72
|
"type-fest": "5.10.0"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "8eed442bbd2c402cdd4a09cd286595bb8feb3951"
|
|
75
75
|
}
|