@esposter/shared 2.38.1 → 2.39.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 +425 -404
- package/dist/index.js +39 -17
- package/package.json +13 -15
package/dist/index.js
CHANGED
|
@@ -104,8 +104,7 @@ let MentionType = /* @__PURE__ */ function(MentionType) {
|
|
|
104
104
|
const MAX_READ_LIMIT = 1e3;
|
|
105
105
|
const SITE_NAME = "Esposter";
|
|
106
106
|
const KIBIBYTE = 1024;
|
|
107
|
-
const
|
|
108
|
-
const GIBIBYTE = MEGABYTE * KIBIBYTE;
|
|
107
|
+
const GIBIBYTE = KIBIBYTE ** 2 * KIBIBYTE;
|
|
109
108
|
//#endregion
|
|
110
109
|
//#region src/models/router/RoutePath.ts
|
|
111
110
|
const RoutePath = {
|
|
@@ -209,7 +208,7 @@ const toAppError = (error) => {
|
|
|
209
208
|
};
|
|
210
209
|
//#endregion
|
|
211
210
|
//#region src/services/error/getResultAsync.ts
|
|
212
|
-
const getResultAsync = (fn) => ResultAsync.
|
|
211
|
+
const getResultAsync = (fn) => ResultAsync.fromThrowable(fn, toAppError)();
|
|
213
212
|
//#endregion
|
|
214
213
|
//#region src/util/time/sleep.ts
|
|
215
214
|
const sleep = (durationMs) => new Promise((resolve) => {
|
|
@@ -373,6 +372,15 @@ const applyItemMetadataMixin = (Base) => class ItemWithMetadata extends Base {
|
|
|
373
372
|
updatedAt = /* @__PURE__ */ new Date();
|
|
374
373
|
};
|
|
375
374
|
//#endregion
|
|
375
|
+
//#region src/util/text/normalizeString.ts
|
|
376
|
+
const normalizeString = (value) => value?.trim() ?? "";
|
|
377
|
+
//#endregion
|
|
378
|
+
//#region src/services/zod/createNormalizedStringSchema.ts
|
|
379
|
+
const createNormalizedStringSchema = (maxLength, schema = z.string()) => schema.transform(normalizeString).pipe(z.string().max(maxLength));
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region src/services/zod/createUniqueArraySchema.ts
|
|
382
|
+
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");
|
|
383
|
+
//#endregion
|
|
376
384
|
//#region src/util/array/chunk.ts
|
|
377
385
|
const chunk = (array, size) => {
|
|
378
386
|
const chunks = [];
|
|
@@ -406,8 +414,29 @@ const takeOne = (values, index = 0) => {
|
|
|
406
414
|
return values[index];
|
|
407
415
|
};
|
|
408
416
|
//#endregion
|
|
409
|
-
//#region src/util/
|
|
410
|
-
const
|
|
417
|
+
//#region src/util/date/getZonedDateTime.ts
|
|
418
|
+
const getZonedDateTime = (date) => Temporal.Instant.fromEpochMilliseconds(date.getTime()).toZonedDateTimeISO(Temporal.Now.timeZoneId());
|
|
419
|
+
//#endregion
|
|
420
|
+
//#region src/util/date/getPlainDate.ts
|
|
421
|
+
const getPlainDate = (date) => getZonedDateTime(date).toPlainDate();
|
|
422
|
+
//#endregion
|
|
423
|
+
//#region src/util/date/checkIsSameDay.ts
|
|
424
|
+
const checkIsSameDay = (date, otherDate) => getPlainDate(date).equals(getPlainDate(otherDate));
|
|
425
|
+
//#endregion
|
|
426
|
+
//#region src/util/date/checkIsToday.ts
|
|
427
|
+
const checkIsToday = (date) => getPlainDate(date).equals(Temporal.Now.plainDateISO());
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region src/util/date/checkIsYesterday.ts
|
|
430
|
+
const checkIsYesterday = (date) => getPlainDate(date).equals(Temporal.Now.plainDateISO().subtract({ days: 1 }));
|
|
431
|
+
//#endregion
|
|
432
|
+
//#region src/util/date/getEndOfDay.ts
|
|
433
|
+
const getEndOfDay = (date) => /* @__PURE__ */ new Date(getZonedDateTime(date).startOfDay().add({ days: 1 }).epochMilliseconds - 1);
|
|
434
|
+
//#endregion
|
|
435
|
+
//#region src/util/date/getStartOfDay.ts
|
|
436
|
+
const getStartOfDay = (date) => new Date(getZonedDateTime(date).startOfDay().epochMilliseconds);
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region src/util/environment/checkIsServer.ts
|
|
439
|
+
const checkIsServer = () => typeof window === "undefined";
|
|
411
440
|
//#endregion
|
|
412
441
|
//#region src/util/id/constants.ts
|
|
413
442
|
const ID_SEPARATOR = "|";
|
|
@@ -448,7 +477,7 @@ const settleAll = async (tasks, concurrencyLimit = tasks.length) => {
|
|
|
448
477
|
if (tasks.length === 0) return [];
|
|
449
478
|
const values = [];
|
|
450
479
|
for (const tasksChunk of chunk(tasks, concurrencyLimit)) {
|
|
451
|
-
const results = await Promise.allSettled(tasksChunk.map((task) => Promise.
|
|
480
|
+
const results = await Promise.allSettled(tasksChunk.map((task) => Promise.try(task)));
|
|
452
481
|
const reasons = [];
|
|
453
482
|
for (const result of results) if (result.status === "rejected") reasons.push(result.reason);
|
|
454
483
|
else values.push(result.value);
|
|
@@ -474,10 +503,6 @@ const encodeUrlSubDelimiters = (value) => Object.entries(EncodedSubDelimiterMap)
|
|
|
474
503
|
//#region src/util/text/getDecodedUriComponent.ts
|
|
475
504
|
const getDecodedUriComponent = (value, fallback) => getResult(() => decodeURIComponent(value)).unwrapOr(fallback);
|
|
476
505
|
//#endregion
|
|
477
|
-
//#region src/util/text/normalizeString.ts
|
|
478
|
-
const normalizeString = (value) => value?.trim() ?? "";
|
|
479
|
-
const createNormalizedStringSchema = (maxLength, schema = z.string()) => schema.transform(normalizeString).pipe(z.string().max(maxLength));
|
|
480
|
-
//#endregion
|
|
481
506
|
//#region src/util/text/streamToText.ts
|
|
482
507
|
const streamToText = async (readable) => {
|
|
483
508
|
readable.setEncoding("utf8");
|
|
@@ -502,7 +527,7 @@ const uncapitalize = (string) => `${string.charAt(0).toLowerCase()}${string.slic
|
|
|
502
527
|
//#endregion
|
|
503
528
|
//#region src/util/time/hrtime.ts
|
|
504
529
|
const hrtime = (previousHrTime) => {
|
|
505
|
-
if (
|
|
530
|
+
if (checkIsServer()) return process.hrtime(previousHrTime);
|
|
506
531
|
const clocktime = performance.now() * .001;
|
|
507
532
|
let seconds = Math.floor(clocktime);
|
|
508
533
|
let nanoseconds = Math.floor(clocktime % 1 * 1e9);
|
|
@@ -530,13 +555,10 @@ const exhaustiveGuard = (value) => {
|
|
|
530
555
|
throw new InvalidOperationError("Read", exhaustiveGuard.name, JSON.stringify(value));
|
|
531
556
|
};
|
|
532
557
|
//#endregion
|
|
533
|
-
//#region src/util/zod/createUniqueArraySchema.ts
|
|
534
|
-
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");
|
|
535
|
-
//#endregion
|
|
536
558
|
//#region src/util/id/uuid/constants.ts
|
|
537
559
|
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;
|
|
538
560
|
//#endregion
|
|
539
|
-
//#region src/util/id/uuid/
|
|
540
|
-
const
|
|
561
|
+
//#region src/util/id/uuid/checkIsUuidV4.ts
|
|
562
|
+
const checkIsUuidV4 = (uuid) => UUIDV4_REGEX.test(uuid);
|
|
541
563
|
//#endregion
|
|
542
|
-
export { AllSpecialValues, CUSTOM_EMOJI_ID_ATTRIBUTE, CUSTOM_EMOJI_NAME_ATTRIBUTE, CUSTOM_EMOJI_TYPE, ForbiddenError, GIBIBYTE, ID_SEPARATOR, InvalidOperationError, ItemEntityTypePropertyNames, ItemMetadata, ItemMetadataPropertyNames, KIBIBYTE, MAX_READ_LIMIT,
|
|
564
|
+
export { AllSpecialValues, CUSTOM_EMOJI_ID_ATTRIBUTE, CUSTOM_EMOJI_NAME_ATTRIBUTE, CUSTOM_EMOJI_TYPE, ForbiddenError, GIBIBYTE, ID_SEPARATOR, InvalidOperationError, ItemEntityTypePropertyNames, ItemMetadata, ItemMetadataPropertyNames, KIBIBYTE, MAX_READ_LIMIT, MENTION_EVERYONE_ID, MENTION_HERE_ID, MENTION_ID_ATTRIBUTE, MENTION_ITEM_TYPE_ATTRIBUTE, MENTION_LABEL_ATTRIBUTE, MENTION_SELECTOR, MENTION_TYPE, MENTION_TYPE_ATTRIBUTE, MentionType, NotFoundError, NotInitializedError, Operation, RoutePath, SITE_NAME, Serializable, UUIDV4_REGEX, UUID_LENGTH, WordFilteredError, applyItemMetadataMixin, capitalize, checkIsPlainObject, checkIsSameDay, checkIsServer, checkIsToday, checkIsUuidV4, checkIsYesterday, chunk, chunkBySerializedSize, classifyMentions, createExponentialBackoff, createItemEntityTypeSchema, createNormalizedStringSchema, createUniqueArraySchema, css, encodeUrlSubDelimiters, exhaustiveGuard, getDecodedUriComponent, getEndOfDay, getMentions, getOrCreate, getPlainDate, getPropertyNames, getRawData, getResult, getResultAsync, getStartOfDay, getZonedDateTime, hrtime, html, itemMetadataSchema, 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": "2.
|
|
3
|
+
"version": "2.39.0",
|
|
4
4
|
"description": "A library that contains shared typescript code.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"error-handling",
|
|
@@ -39,39 +39,37 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
|
-
"build": "
|
|
43
|
-
"export:gen": "
|
|
42
|
+
"build": "tsdown",
|
|
43
|
+
"export:gen": "generate-exports",
|
|
44
44
|
"format": "oxfmt",
|
|
45
45
|
"format:check": "oxfmt --check",
|
|
46
46
|
"lint": "eslint .",
|
|
47
47
|
"lint:fix": "eslint --fix .",
|
|
48
48
|
"test": "vitest",
|
|
49
|
-
"typecheck": "
|
|
49
|
+
"typecheck": "tsc"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"neverthrow": "^8.2.0",
|
|
53
|
-
"node-html-parser": "^9.0.
|
|
53
|
+
"node-html-parser": "^9.0.3",
|
|
54
54
|
"sanitize-html": "^2.17.7"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@arethetypeswrong/core": "^0.18.5",
|
|
58
58
|
"@azure/data-tables": "^13.3.2",
|
|
59
|
-
"@esposter/configuration": "2.
|
|
60
|
-
"@types/node": "^26.
|
|
59
|
+
"@esposter/configuration": "2.39.0",
|
|
60
|
+
"@types/node": "^26.4.1",
|
|
61
61
|
"@types/sanitize-html": "^2.16.1",
|
|
62
|
-
"ctix": "^2.8.2",
|
|
63
62
|
"publint": "^0.3.24",
|
|
64
|
-
"tsdown": "^0.
|
|
65
|
-
"type-fest": "^5.
|
|
63
|
+
"tsdown": "^0.23.0",
|
|
64
|
+
"type-fest": "^5.9.0",
|
|
66
65
|
"vitest": "^4.1.11",
|
|
67
|
-
"vue": "^3.5.
|
|
66
|
+
"vue": "^3.5.42"
|
|
68
67
|
},
|
|
69
68
|
"peerDependencies": {
|
|
70
|
-
"zod": "^4.4
|
|
69
|
+
"zod": "^4.5.4"
|
|
71
70
|
},
|
|
72
71
|
"inlinedDependencies": {
|
|
73
|
-
"
|
|
74
|
-
"type-fest": "5.8.0"
|
|
72
|
+
"type-fest": "5.9.0"
|
|
75
73
|
},
|
|
76
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "98f89a176510bb274865731121f990e48c6d056a"
|
|
77
75
|
}
|