@esposter/shared 3.5.1 → 3.6.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 CHANGED
@@ -2,12 +2,6 @@ import { z } from "zod";
2
2
  import { Result, ResultAsync } from "neverthrow";
3
3
  import { HTMLElement } from "node-html-parser";
4
4
  import baseSanitizeHtml from "sanitize-html";
5
- //#region src/test/constants.d.ts
6
- export declare const ALL_SPECIAL_VALUES: {
7
- isPlainObject: boolean;
8
- value: unknown;
9
- }[];
10
- //#endregion
11
5
  //#region src/models/error/ForbiddenError.d.ts
12
6
  export declare class ForbiddenError extends Error {
13
7
  constructor(message: string);
@@ -58,7 +52,6 @@ export interface MaybeReactive {
58
52
  export declare const RoutePath: {
59
53
  readonly About: "/about";
60
54
  readonly Achievements: "/achievements";
61
- readonly AgentConsole: "/agent-console";
62
55
  readonly Anime: "/anime";
63
56
  readonly Calls: (id: string) => string;
64
57
  readonly CallsIndex: "/calls";
@@ -66,6 +59,7 @@ export declare const RoutePath: {
66
59
  readonly Docs: "/docs";
67
60
  readonly Dungeons: "/dungeons";
68
61
  readonly FluidSimulator: "/fluid-simulator";
62
+ readonly Genshin: "/genshin";
69
63
  readonly Github: "https://github.com/Esposter/Esposter";
70
64
  readonly Index: "/";
71
65
  readonly Login: "/login";
@@ -1933,7 +1927,7 @@ const rawCliOptions: KebabCasedProperties<CliOptions> = {
1933
1927
  type KebabCase<Value, Options extends WordsOptions = {}> = DelimiterCase<Value, '-', ApplyDefaultOptions<WordsOptions, _DefaultDelimiterCaseOptions, Options>>;
1934
1928
  //#endregion
1935
1929
  //#region src/models/shared/ItemMetadataClass.d.ts
1936
- export interface ItemMetadataClass<TBase extends Class<NonNullable<unknown>>> {
1930
+ export interface ItemMetadataClass<TBase extends Class<object>> {
1937
1931
  new (...args: ConstructorParameters<TBase>): InstanceType<TBase> & ItemMetadata;
1938
1932
  prototype: InstanceType<TBase> & ItemMetadata;
1939
1933
  }
@@ -1949,11 +1943,14 @@ export interface TakeOne {
1949
1943
  <T extends object>(values: T, index: keyof T): T[keyof T];
1950
1944
  }
1951
1945
  //#endregion
1946
+ //#region src/util/types/FunctionLike.d.ts
1947
+ export type FunctionLike = ((...args: never) => unknown) | (abstract new (...args: never) => unknown);
1948
+ //#endregion
1952
1949
  //#region src/util/types/DeepOmit.d.ts
1953
- export type DeepOmit<T, TKey extends PropertyKey> = [T] extends [Date | Function | Primitive] ? T : [Record<string, unknown>] extends [T] ? T : T extends object ? T extends unknown[] ? T extends readonly unknown[] ? { [K in keyof T]: DeepOmit<T[K], TKey>; } : DeepOmit<T[number], TKey>[] : { [P in keyof T as P extends TKey ? never : P]: DeepOmit<T[P], TKey>; } : T;
1950
+ export type DeepOmit<T, TKey extends PropertyKey> = [T] extends [Date | FunctionLike | Primitive] ? T : [Record<string, unknown>] extends [T] ? T : T extends object ? T extends unknown[] ? T extends readonly unknown[] ? { [K in keyof T]: DeepOmit<T[K], TKey>; } : DeepOmit<T[number], TKey>[] : { [P in keyof T as P extends TKey ? never : P]: DeepOmit<T[P], TKey>; } : T;
1954
1951
  //#endregion
1955
1952
  //#region src/util/types/DeepOptionalUndefined.d.ts
1956
- export type DeepOptionalUndefined<T> = T extends Date | Function | Primitive ? T : T extends unknown[] ? { [K in keyof T]: DeepOptionalUndefined<T[K]>; } : T extends object ? { [K in keyof T as undefined extends T[K] ? K : never]?: DeepOptionalUndefined<T[K]>; } & { [K in keyof T as undefined extends T[K] ? never : K]: DeepOptionalUndefined<T[K]>; } extends (infer O) ? { [K in keyof O]: O[K]; } : never : T;
1953
+ export type DeepOptionalUndefined<T> = T extends Date | FunctionLike | Primitive ? T : T extends unknown[] ? { [K in keyof T]: DeepOptionalUndefined<T[K]>; } : T extends object ? { [K in keyof T as undefined extends T[K] ? K : never]?: DeepOptionalUndefined<T[K]>; } & { [K in keyof T as undefined extends T[K] ? never : K]: DeepOptionalUndefined<T[K]>; } extends (infer O) ? { [K in keyof O]: O[K]; } : never : T;
1957
1954
  //#endregion
1958
1955
  //#region src/models/shared/ToData.d.ts
1959
1956
  export type ToData<T> = DeepOptionalUndefined<DeepOmit<T, "toJSON">>;
@@ -2013,7 +2010,7 @@ export declare const sanitizeHtml: (...[html, options]: Parameters<typeof baseSa
2013
2010
  export declare const sanitizeTextHtml: (html: string) => string;
2014
2011
  //#endregion
2015
2012
  //#region src/services/shared/applyItemMetadataMixin.d.ts
2016
- export declare const applyItemMetadataMixin: <TBase extends Class<NonNullable<unknown>>>(Base: TBase) => ItemMetadataClass<TBase>;
2013
+ export declare const applyItemMetadataMixin: <TBase extends Class<object>>(Base: TBase) => ItemMetadataClass<TBase>;
2017
2014
  //#endregion
2018
2015
  //#region src/services/zod/createNormalizedStringSchema.d.ts
2019
2016
  export declare const createNormalizedStringSchema: (maxLength: number, schema?: z.ZodString) => z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, z.ZodString>;
@@ -2029,6 +2026,12 @@ export declare const MAX_WINDOW_LOG = 27;
2029
2026
  //#region src/services/zstd/getWindowLog.d.ts
2030
2027
  export declare const getWindowLog: (dictionaryByteCount: number, inputByteCount: number) => number;
2031
2028
  //#endregion
2029
+ //#region src/test/constants.d.ts
2030
+ export declare const ALL_SPECIAL_VALUES: {
2031
+ isPlainObject: boolean;
2032
+ value: unknown;
2033
+ }[];
2034
+ //#endregion
2032
2035
  //#region src/util/array/chunk.d.ts
2033
2036
  export declare const chunk: <T>(array: T[], size: number) => T[][];
2034
2037
  //#endregion
@@ -2047,12 +2050,19 @@ export declare const getZonedDateTime: (date: Date) => Temporal.ZonedDateTime;
2047
2050
  //#region src/util/environment/checkIsServer.d.ts
2048
2051
  export declare const checkIsServer: () => boolean;
2049
2052
  //#endregion
2053
+ //#region src/util/function/getSynchronizedFunction.d.ts
2054
+ export declare const getSynchronizedFunction: <TArgs extends unknown[]>(asyncFunction: (...args: TArgs) => Promise<unknown>) => ((...args: TArgs) => void);
2055
+ export declare const waitForSynchronizedFunctions: () => Promise<void>;
2056
+ //#endregion
2050
2057
  //#region src/util/function/noop.d.ts
2051
2058
  export declare const noop: () => void;
2052
2059
  //#endregion
2053
2060
  //#region src/util/id/constants.d.ts
2054
2061
  export declare const ID_SEPARATOR = "|";
2055
2062
  //#endregion
2063
+ //#region src/util/id/uuid/constants.d.ts
2064
+ export declare const UUIDV4_REGEX: RegExp;
2065
+ //#endregion
2056
2066
  //#region src/util/map/getOrCreate.d.ts
2057
2067
  export declare const getOrCreate: <TKey, TValue>(map: Map<TKey, TValue>, key: TKey, create: () => TValue) => TValue;
2058
2068
  //#endregion
@@ -2069,7 +2079,7 @@ export type GetArrayProps<T extends unknown[], P extends string, D extends unkno
2069
2079
  export type KnownKeys<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K]; };
2070
2080
  //#endregion
2071
2081
  //#region src/util/types/GetObjectProps.d.ts
2072
- export type GetObjectProps<T, P extends string, D extends unknown[], R extends boolean> = { [K in keyof KnownKeys<T> & (number | string)]: K extends `${number}` ? never : NonNullable<T[K]> extends Function ? never : (D extends [unknown, ...infer Rest] ? GetProperties<T[K], R extends true ? `${K}` : `${P}.${K}`, Rest, false> : never) | {
2082
+ export type GetObjectProps<T, P extends string, D extends unknown[], R extends boolean> = { [K in keyof KnownKeys<T> & (number | string)]: K extends `${number}` ? never : NonNullable<T[K]> extends FunctionLike ? never : (D extends [unknown, ...infer Rest] ? GetProperties<T[K], R extends true ? `${K}` : `${P}.${K}`, Rest, false> : never) | {
2073
2083
  path: R extends true ? `${K}` : `${P}.${K}`;
2074
2084
  value: T[K];
2075
2085
  }; }[keyof KnownKeys<T> & (number | string)];
@@ -2152,7 +2162,7 @@ export declare const sleep: (durationMs: number) => Promise<void>;
2152
2162
  export type BuildTuple<N extends number, T = unknown, R extends unknown[] = []> = R["length"] extends N ? R : BuildTuple<N, T, [...R, T]>;
2153
2163
  //#endregion
2154
2164
  //#region src/util/types/FunctionProperties.d.ts
2155
- export type FunctionProperties<T> = { [K in keyof T]: T[K] extends Function ? K : never; };
2165
+ export type FunctionProperties<T> = { [K in keyof T]: T[K] extends FunctionLike ? K : never; };
2156
2166
  //#endregion
2157
2167
  //#region src/util/types/ExcludeFunctionProperties.d.ts
2158
2168
  export type ExcludeFunctionProperties<T> = Except<T, FunctionProperties<T>[keyof T]>;
@@ -2171,7 +2181,4 @@ export type TupleSlice<T extends unknown[], S extends number, E extends number =
2171
2181
  //#endregion
2172
2182
  //#region src/util/validation/exhaustiveGuard.d.ts
2173
2183
  export declare const exhaustiveGuard: (value: never) => never;
2174
- //#endregion
2175
- //#region src/util/id/uuid/constants.d.ts
2176
- export declare const UUIDV4_REGEX: RegExp;
2177
2184
  //#endregion
package/dist/index.js CHANGED
@@ -2,57 +2,6 @@ import { z } from "zod";
2
2
  import { ResultAsync, fromThrowable } from "neverthrow";
3
3
  import { parse } from "node-html-parser";
4
4
  import baseSanitizeHtml from "sanitize-html";
5
- //#region src/util/function/noop.ts
6
- const noop = () => {};
7
- //#endregion
8
- //#region src/test/constants.ts
9
- const ALL_SPECIAL_VALUES = [
10
- {
11
- isPlainObject: true,
12
- value: {}
13
- },
14
- {
15
- isPlainObject: true,
16
- value: Object.create(null)
17
- },
18
- {
19
- isPlainObject: false,
20
- value: []
21
- },
22
- {
23
- isPlainObject: false,
24
- value: /* @__PURE__ */ new Date()
25
- },
26
- {
27
- isPlainObject: false,
28
- value: null
29
- },
30
- {
31
- isPlainObject: false,
32
- value: void 0
33
- },
34
- {
35
- isPlainObject: false,
36
- value: ""
37
- },
38
- {
39
- isPlainObject: false,
40
- value: 0
41
- },
42
- {
43
- isPlainObject: false,
44
- value: Symbol("")
45
- },
46
- {
47
- isPlainObject: false,
48
- value: noop
49
- },
50
- {
51
- isPlainObject: false,
52
- value: /(?:)/u
53
- }
54
- ];
55
- //#endregion
56
5
  //#region src/models/error/ForbiddenError.ts
57
6
  var ForbiddenError = class extends Error {
58
7
  constructor(message) {
@@ -110,7 +59,6 @@ const GIBIBYTE = KIBIBYTE ** 2 * KIBIBYTE;
110
59
  const RoutePath = {
111
60
  About: "/about",
112
61
  Achievements: "/achievements",
113
- AgentConsole: "/agent-console",
114
62
  Anime: "/anime",
115
63
  Calls: (id) => `/calls/${id}`,
116
64
  CallsIndex: "/calls",
@@ -118,6 +66,7 @@ const RoutePath = {
118
66
  Docs: "/docs",
119
67
  Dungeons: "/dungeons",
120
68
  FluidSimulator: "/fluid-simulator",
69
+ Genshin: "/genshin",
121
70
  Github: `https://github.com/${SITE_NAME}/${SITE_NAME}`,
122
71
  Index: "/",
123
72
  Login: "/login",
@@ -204,6 +153,9 @@ const getResult = (callback) => fromThrowable(callback, toAppError)();
204
153
  //#region src/services/error/getResultAsync.ts
205
154
  const getResultAsync = (callback) => ResultAsync.fromThrowable(callback, toAppError)();
206
155
  //#endregion
156
+ //#region src/util/function/noop.ts
157
+ const noop = () => {};
158
+ //#endregion
207
159
  //#region src/services/error/withFinalizer.ts
208
160
  const withFinalizer = (callback, finalizer) => {
209
161
  const callbackResult = getResult(callback);
@@ -396,6 +348,54 @@ const MAX_WINDOW_LOG = 27;
396
348
  //#region src/services/zstd/getWindowLog.ts
397
349
  const getWindowLog = (dictionaryByteCount, inputByteCount) => Math.min(27, Math.max(10, Math.ceil(Math.log2(dictionaryByteCount + inputByteCount + 1))));
398
350
  //#endregion
351
+ //#region src/test/constants.ts
352
+ const ALL_SPECIAL_VALUES = [
353
+ {
354
+ isPlainObject: true,
355
+ value: {}
356
+ },
357
+ {
358
+ isPlainObject: true,
359
+ value: Object.create(null)
360
+ },
361
+ {
362
+ isPlainObject: false,
363
+ value: []
364
+ },
365
+ {
366
+ isPlainObject: false,
367
+ value: /* @__PURE__ */ new Date()
368
+ },
369
+ {
370
+ isPlainObject: false,
371
+ value: null
372
+ },
373
+ {
374
+ isPlainObject: false,
375
+ value: void 0
376
+ },
377
+ {
378
+ isPlainObject: false,
379
+ value: ""
380
+ },
381
+ {
382
+ isPlainObject: false,
383
+ value: 0
384
+ },
385
+ {
386
+ isPlainObject: false,
387
+ value: Symbol("")
388
+ },
389
+ {
390
+ isPlainObject: false,
391
+ value: noop
392
+ },
393
+ {
394
+ isPlainObject: false,
395
+ value: /(?:)/u
396
+ }
397
+ ];
398
+ //#endregion
399
399
  //#region src/util/array/chunk.ts
400
400
  const chunk = (array, size) => {
401
401
  const chunks = [];
@@ -438,9 +438,24 @@ const getEndOfDay = (date) => /* @__PURE__ */ new Date(getZonedDateTime(date).st
438
438
  //#region src/util/environment/checkIsServer.ts
439
439
  const checkIsServer = () => typeof window === "undefined";
440
440
  //#endregion
441
+ //#region src/util/function/getSynchronizedFunction.ts
442
+ const pendingPromises = /* @__PURE__ */ new Set();
443
+ const getSynchronizedFunction = (asyncFunction) => (...args) => {
444
+ const promise = asyncFunction(...args).finally(() => {
445
+ pendingPromises.delete(promise);
446
+ });
447
+ pendingPromises.add(promise);
448
+ };
449
+ const waitForSynchronizedFunctions = async () => {
450
+ await Promise.allSettled(pendingPromises);
451
+ };
452
+ //#endregion
441
453
  //#region src/util/id/constants.ts
442
454
  const ID_SEPARATOR = "|";
443
455
  //#endregion
456
+ //#region src/util/id/uuid/constants.ts
457
+ 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;
458
+ //#endregion
444
459
  //#region src/util/map/getOrCreate.ts
445
460
  const getOrCreate = (map, key, create) => {
446
461
  if (map.has(key)) return map.get(key);
@@ -562,7 +577,4 @@ const exhaustiveGuard = (value) => {
562
577
  throw new InvalidOperationError("Read", exhaustiveGuard.name, JSON.stringify(value));
563
578
  };
564
579
  //#endregion
565
- //#region src/util/id/uuid/constants.ts
566
- 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;
567
- //#endregion
568
- 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 };
580
+ 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, getSynchronizedFunction, getWindowLog, getZonedDateTime, hrtime, html, jsonDateParse, mergeObjectsStrict, noop, normalizeString, now, sanitizeHtml, sanitizeTextHtml, settleAll, sleep, streamToText, takeOne, toAppError, toKebabCase, toRawDeep, truncate, uncapitalize, waitForSynchronizedFunctions, withFinalizer, withFinalizerAsync };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esposter/shared",
3
- "version": "3.5.1",
3
+ "version": "3.6.0",
4
4
  "description": "A library that contains shared typescript code.",
5
5
  "keywords": [
6
6
  "error-handling",
@@ -40,7 +40,6 @@
40
40
  },
41
41
  "scripts": {
42
42
  "build": "tsdown",
43
- "export:gen": "generate-exports",
44
43
  "format": "oxfmt",
45
44
  "format:check": "oxfmt --check",
46
45
  "lint": "eslint .",
@@ -56,9 +55,9 @@
56
55
  "devDependencies": {
57
56
  "@arethetypeswrong/core": "^0.18.5",
58
57
  "@azure/data-tables": "^13.3.2",
59
- "@esposter/configuration": "3.5.1",
58
+ "@esposter/configuration": "3.6.0",
60
59
  "@types/node": "^26.6.3",
61
- "@types/sanitize-html": "^2.16.1",
60
+ "@types/sanitize-html": "^2.16.2",
62
61
  "publint": "^0.3.24",
63
62
  "tsdown": "^0.23.0",
64
63
  "type-fest": "^5.10.0",
@@ -71,5 +70,5 @@
71
70
  "inlinedDependencies": {
72
71
  "type-fest": "5.10.0"
73
72
  },
74
- "gitHead": "69b1fb432ea9261d04104f25308cc9f66c8c8594"
73
+ "gitHead": "07f63a48503626e6f02f64e778a2e8e4838b55e2"
75
74
  }