@naturalcycles/js-lib 15.62.0 → 15.64.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/array/sort.d.ts +10 -10
- package/dist/array/sort.js +1 -1
- package/dist/bot.model.js +2 -1
- package/dist/browser/adminService.js +1 -0
- package/dist/browser/analytics.util.js +4 -3
- package/dist/browser/i18n/translation.service.js +1 -1
- package/dist/browser/topbar.d.ts +3 -3
- package/dist/datetime/localTime.d.ts +9 -0
- package/dist/datetime/localTime.js +13 -1
- package/dist/decorators/asyncMemo.decorator.js +2 -2
- package/dist/error/assert.d.ts +1 -2
- package/dist/error/errorMode.js +2 -1
- package/dist/promise/pGradualQueue.d.ts +1 -1
- package/dist/promise/pGradualQueue.js +1 -1
- package/dist/promise/pMap.d.ts +1 -1
- package/dist/promise/pMap.js +1 -1
- package/dist/promise/pQueue.d.ts +1 -1
- package/dist/promise/pQueue.js +1 -1
- package/dist/promise/pTimeout.js +0 -1
- package/dist/typeFest.d.ts +1 -1
- package/dist/validation/validation.d.ts +1 -1
- package/dist/zod/zod.util.d.ts +4 -4
- package/dist/zod/zod.util.js +3 -1
- package/package.json +3 -2
- package/src/array/sort.ts +11 -16
- package/src/browser/adminService.ts +1 -0
- package/src/browser/analytics.util.ts +4 -5
- package/src/datetime/localTime.ts +12 -0
- package/src/promise/pGradualQueue.ts +2 -5
- package/src/promise/pMap.ts +2 -1
- package/src/promise/pQueue.ts +2 -5
- package/src/promise/pTimeout.ts +0 -1
- package/src/validation/validation.ts +2 -2
- package/src/zod/zod.util.ts +5 -5
package/dist/array/sort.d.ts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Comparator, Mapper, SortDirection, SortOptions, StringMap } from '../types.js';
|
|
2
2
|
declare class Comparators {
|
|
3
3
|
/**
|
|
4
4
|
* Good for numbers.
|
|
5
5
|
*/
|
|
6
|
-
numericAsc(a: number, b: number): number;
|
|
7
|
-
numericDesc(a: number, b: number): number;
|
|
8
|
-
localeAsc(a: string, b: string): number;
|
|
9
|
-
localeDesc(a: string, b: string): number;
|
|
10
|
-
by<T, COMPARE_TYPE extends string | number>(mapper: Mapper<T, COMPARE_TYPE>, opt?: ComparatorByOptions): Comparator<T>;
|
|
11
|
-
updatedAsc(a: {
|
|
6
|
+
numericAsc(this: void, a: number, b: number): number;
|
|
7
|
+
numericDesc(this: void, a: number, b: number): number;
|
|
8
|
+
localeAsc(this: void, a: string, b: string): number;
|
|
9
|
+
localeDesc(this: void, a: string, b: string): number;
|
|
10
|
+
by<T, COMPARE_TYPE extends string | number>(this: void, mapper: Mapper<T, COMPARE_TYPE>, opt?: ComparatorByOptions): Comparator<T>;
|
|
11
|
+
updatedAsc(this: void, a: {
|
|
12
12
|
updated: number;
|
|
13
13
|
}, b: {
|
|
14
14
|
updated: number;
|
|
15
15
|
}): number;
|
|
16
|
-
updatedDesc(a: {
|
|
16
|
+
updatedDesc(this: void, a: {
|
|
17
17
|
updated: number;
|
|
18
18
|
}, b: {
|
|
19
19
|
updated: number;
|
|
20
20
|
}): number;
|
|
21
|
-
createdAsc(a: {
|
|
21
|
+
createdAsc(this: void, a: {
|
|
22
22
|
created: number;
|
|
23
23
|
}, b: {
|
|
24
24
|
created: number;
|
|
25
25
|
}): number;
|
|
26
|
-
createdDesc(a: {
|
|
26
|
+
createdDesc(this: void, a: {
|
|
27
27
|
created: number;
|
|
28
28
|
}, b: {
|
|
29
29
|
created: number;
|
package/dist/array/sort.js
CHANGED
package/dist/bot.model.js
CHANGED
|
@@ -8,7 +8,6 @@ export async function loadGTag(gtagId, enabled = true) {
|
|
|
8
8
|
return;
|
|
9
9
|
globalThis.dataLayer ||= [];
|
|
10
10
|
globalThis.gtag ||= function gtag() {
|
|
11
|
-
// biome-ignore lint/complexity/noArguments: ok
|
|
12
11
|
globalThis.dataLayer.push(arguments);
|
|
13
12
|
};
|
|
14
13
|
globalThis.gtag('js', new Date());
|
|
@@ -30,14 +29,16 @@ export async function loadGTM(gtmId, enabled = true) {
|
|
|
30
29
|
await loadScript(`https://www.googletagmanager.com/gtm.js?id=${gtmId}`);
|
|
31
30
|
}
|
|
32
31
|
export function loadHotjar(hjid) {
|
|
33
|
-
if (isServerSide())
|
|
32
|
+
if (isServerSide()) {
|
|
34
33
|
return;
|
|
34
|
+
}
|
|
35
|
+
/* eslint-disable */
|
|
36
|
+
// oxfmt-ignore
|
|
35
37
|
;
|
|
36
38
|
((h, o, t, j, a, r) => {
|
|
37
39
|
h.hj =
|
|
38
40
|
h.hj ||
|
|
39
41
|
function hj() {
|
|
40
|
-
// biome-ignore lint/complexity/noArguments: ok
|
|
41
42
|
;
|
|
42
43
|
(h.hj.q = h.hj.q || []).push(arguments);
|
|
43
44
|
};
|
|
@@ -35,7 +35,7 @@ export class TranslationService {
|
|
|
35
35
|
*/
|
|
36
36
|
async loadLocale(locale) {
|
|
37
37
|
const locales = Array.isArray(locale) ? locale : [locale];
|
|
38
|
-
await pMap(locales, async
|
|
38
|
+
await pMap(locales, async locale => {
|
|
39
39
|
if (this.locales[locale])
|
|
40
40
|
return; // already loaded
|
|
41
41
|
this.locales[locale] = await this.cfg.translationLoader.load(locale);
|
package/dist/browser/topbar.d.ts
CHANGED
|
@@ -16,8 +16,8 @@ export interface TopBarOptions {
|
|
|
16
16
|
}
|
|
17
17
|
export declare const topbar: {
|
|
18
18
|
config(opts: TopBarOptions): void;
|
|
19
|
-
set(show: boolean, opts?: TopBarOptions): void;
|
|
20
|
-
show(opts?: TopBarOptions): void;
|
|
21
|
-
progress(to:
|
|
19
|
+
set(show: boolean, opts?: TopBarOptions | undefined): void;
|
|
20
|
+
show(opts?: TopBarOptions | undefined): void;
|
|
21
|
+
progress(to: string | number): any;
|
|
22
22
|
hide(): void;
|
|
23
23
|
};
|
|
@@ -208,6 +208,15 @@ export declare class LocalTime {
|
|
|
208
208
|
* `1984-06-21 17:56`
|
|
209
209
|
*/
|
|
210
210
|
toPretty(seconds?: boolean): IsoDateTime;
|
|
211
|
+
/**
|
|
212
|
+
* Returns e.g: `1984-06-21T17:56:21Z`
|
|
213
|
+
*
|
|
214
|
+
* IsoDateTime "format" is ambiguous.
|
|
215
|
+
* Normally what we mean by it is `1984-06-21T17:56:21` (without Z).
|
|
216
|
+
* But sometimes you need Z.
|
|
217
|
+
* So, when you need Z - use this function.
|
|
218
|
+
*/
|
|
219
|
+
toISODateTimeWithZ(): IsoDateTime;
|
|
211
220
|
/**
|
|
212
221
|
* Returns e.g: `1984-06-21T17:56:21`
|
|
213
222
|
*/
|
|
@@ -2,7 +2,8 @@ import { _assert } from '../error/assert.js';
|
|
|
2
2
|
import { localDate } from './localDate.js';
|
|
3
3
|
import { _ms } from './time.util.js';
|
|
4
4
|
import { WallTime } from './wallTime.js';
|
|
5
|
-
export
|
|
5
|
+
export { ISODayOfWeek };
|
|
6
|
+
var ISODayOfWeek;
|
|
6
7
|
(function (ISODayOfWeek) {
|
|
7
8
|
ISODayOfWeek[ISODayOfWeek["MONDAY"] = 1] = "MONDAY";
|
|
8
9
|
ISODayOfWeek[ISODayOfWeek["TUESDAY"] = 2] = "TUESDAY";
|
|
@@ -568,6 +569,17 @@ export class LocalTime {
|
|
|
568
569
|
// const s = this.$date.toISOString()
|
|
569
570
|
// return s.slice(0, 10) + ' ' + s.slice(11, seconds ? 19 : 16)
|
|
570
571
|
}
|
|
572
|
+
/**
|
|
573
|
+
* Returns e.g: `1984-06-21T17:56:21Z`
|
|
574
|
+
*
|
|
575
|
+
* IsoDateTime "format" is ambiguous.
|
|
576
|
+
* Normally what we mean by it is `1984-06-21T17:56:21` (without Z).
|
|
577
|
+
* But sometimes you need Z.
|
|
578
|
+
* So, when you need Z - use this function.
|
|
579
|
+
*/
|
|
580
|
+
toISODateTimeWithZ() {
|
|
581
|
+
return (this.toISODateTime() + 'Z');
|
|
582
|
+
}
|
|
571
583
|
/**
|
|
572
584
|
* Returns e.g: `1984-06-21T17:56:21`
|
|
573
585
|
*/
|
|
@@ -46,7 +46,7 @@ export const _AsyncMemo = (opt) => (target, key, descriptor) => {
|
|
|
46
46
|
// console.log('return promise', promiseCache.size)
|
|
47
47
|
return promise;
|
|
48
48
|
}
|
|
49
|
-
promise = cache.get(cacheKey).then(async
|
|
49
|
+
promise = cache.get(cacheKey).then(async value => {
|
|
50
50
|
if (value !== MISS) {
|
|
51
51
|
// console.log('hit', promiseCache.size)
|
|
52
52
|
promiseCache.delete(cacheKey);
|
|
@@ -55,7 +55,7 @@ export const _AsyncMemo = (opt) => (target, key, descriptor) => {
|
|
|
55
55
|
// Miss
|
|
56
56
|
// console.log('miss', promiseCache.size)
|
|
57
57
|
return await onMiss();
|
|
58
|
-
}, async
|
|
58
|
+
}, async err => {
|
|
59
59
|
// Log the cache error and proceed "as cache Miss"
|
|
60
60
|
logger.error(err);
|
|
61
61
|
return await onMiss();
|
package/dist/error/assert.d.ts
CHANGED
|
@@ -16,8 +16,7 @@ import type { BackendErrorResponseObject, ErrorData, ErrorObject } from './error
|
|
|
16
16
|
*
|
|
17
17
|
* Since 2024-07-10 it no longer sets `userFriendly: true` by default.
|
|
18
18
|
*/
|
|
19
|
-
export declare function _assert(condition: any,
|
|
20
|
-
message?: string, errorData?: ErrorData): asserts condition;
|
|
19
|
+
export declare function _assert(condition: any, message?: string, errorData?: ErrorData): asserts condition;
|
|
21
20
|
/**
|
|
22
21
|
* Like _assert(), but prints more helpful error message.
|
|
23
22
|
* API is similar to Node's assert.equals().
|
package/dist/error/errorMode.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
export { ErrorMode };
|
|
1
2
|
/**
|
|
2
3
|
* Allows to define error-controlling behaviour for batch operations.
|
|
3
4
|
*
|
|
4
5
|
* @default is THROW_IMMEDIATELY in most cases
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
+
var ErrorMode;
|
|
7
8
|
(function (ErrorMode) {
|
|
8
9
|
/**
|
|
9
10
|
* Usually a default behaviour, similar as "exit early".
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorMode } from '../error/errorMode.js';
|
|
2
|
-
import {
|
|
2
|
+
import type { CommonLogger, CommonLogLevel } from '../log/commonLogger.js';
|
|
3
3
|
import type { AsyncFunction, PositiveInteger } from '../types.js';
|
|
4
4
|
export interface PGradualQueueCfg {
|
|
5
5
|
concurrency: PositiveInteger;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorMode } from '../error/errorMode.js';
|
|
2
|
-
import { createCommonLoggerAtLevel
|
|
2
|
+
import { createCommonLoggerAtLevel } from '../log/commonLogger.js';
|
|
3
3
|
import { pDefer } from './pDefer.js';
|
|
4
4
|
/**
|
|
5
5
|
* A queue similar to PQueue that gradually increases concurrency from 1 to the configured
|
package/dist/promise/pMap.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ErrorMode } from '../error/errorMode.js';
|
|
2
2
|
import type { CommonLogger } from '../log/commonLogger.js';
|
|
3
|
-
import {
|
|
3
|
+
import type { AbortableAsyncMapper } from '../types.js';
|
|
4
4
|
export interface PMapOptions {
|
|
5
5
|
/**
|
|
6
6
|
* Number of concurrently pending promises returned by `mapper`.
|
package/dist/promise/pMap.js
CHANGED
|
@@ -77,7 +77,7 @@ export async function pMap(iterable, mapper, opt = {}) {
|
|
|
77
77
|
}
|
|
78
78
|
resolvingCount++;
|
|
79
79
|
Promise.resolve(nextItem)
|
|
80
|
-
.then(async
|
|
80
|
+
.then(async element => await mapper(element, i))
|
|
81
81
|
.then(value => {
|
|
82
82
|
if (value === END) {
|
|
83
83
|
isSettled = true;
|
package/dist/promise/pQueue.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorMode } from '../error/errorMode.js';
|
|
2
|
-
import {
|
|
2
|
+
import type { CommonLogger, CommonLogLevel } from '../log/commonLogger.js';
|
|
3
3
|
import type { AsyncFunction, PositiveInteger } from '../types.js';
|
|
4
4
|
export interface PQueueCfg {
|
|
5
5
|
concurrency: PositiveInteger;
|
package/dist/promise/pQueue.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorMode } from '../error/errorMode.js';
|
|
2
|
-
import { createCommonLoggerAtLevel
|
|
2
|
+
import { createCommonLoggerAtLevel } from '../log/commonLogger.js';
|
|
3
3
|
import { pDefer } from './pDefer.js';
|
|
4
4
|
/**
|
|
5
5
|
* Inspired by: https://github.com/sindresorhus/p-queue
|
package/dist/promise/pTimeout.js
CHANGED
|
@@ -29,7 +29,6 @@ export async function pTimeout(fn, opt) {
|
|
|
29
29
|
}
|
|
30
30
|
const { timeout, name = fn.name || 'pTimeout function', onTimeout } = opt;
|
|
31
31
|
const fakeError = opt.fakeError || new Error('TimeoutError');
|
|
32
|
-
// biome-ignore lint/suspicious/noAsyncPromiseExecutor: ok
|
|
33
32
|
return await new Promise(async (resolve, reject) => {
|
|
34
33
|
// Prepare the timeout timer
|
|
35
34
|
const timer = setTimeout(() => {
|
package/dist/typeFest.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export type Simplify<T> = {
|
|
|
12
12
|
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
13
13
|
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
14
14
|
*/
|
|
15
|
-
export type IsEqual<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? true : false;
|
|
15
|
+
export type IsEqual<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => (G extends U ? 1 : 2) ? true : false;
|
|
16
16
|
/**
|
|
17
17
|
* Filter out keys from an object.
|
|
18
18
|
* Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
@@ -14,7 +14,7 @@ import type { AppError } from '../error/error.util.js';
|
|
|
14
14
|
*
|
|
15
15
|
* @experimental
|
|
16
16
|
*/
|
|
17
|
-
export type ValidationFunction<
|
|
17
|
+
export type ValidationFunction<OUT, ERR extends AppError> = (input: unknown, opt?: ValidationFunctionOptions) => ValidationFunctionResult<OUT, ERR>;
|
|
18
18
|
export type ValidationFunctionResult<OUT, ERR extends AppError> = [err: ERR | null, output: OUT];
|
|
19
19
|
export interface ValidationFunctionOptions {
|
|
20
20
|
/**
|
package/dist/zod/zod.util.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import type { ZodError, ZodType } from 'zod';
|
|
|
2
2
|
import type { ErrorData } from '../error/error.model.js';
|
|
3
3
|
import { AppError } from '../error/error.util.js';
|
|
4
4
|
import type { ValidationFunction, ValidationFunctionResult } from '../validation/validation.js';
|
|
5
|
-
export declare function getZodValidationFunction<T>(schema: ZodType<T>): ValidationFunction<T,
|
|
6
|
-
export declare function zIsValid<T>(value:
|
|
7
|
-
export declare function zValidate<T>(value:
|
|
8
|
-
export declare function zSafeValidate<T>(input:
|
|
5
|
+
export declare function getZodValidationFunction<T>(schema: ZodType<T>): ValidationFunction<T, ZodValidationError>;
|
|
6
|
+
export declare function zIsValid<T>(value: unknown, schema: ZodType<T>): boolean;
|
|
7
|
+
export declare function zValidate<T>(value: unknown, schema: ZodType<T>): T;
|
|
8
|
+
export declare function zSafeValidate<T>(input: unknown, schema: ZodType<T>): ValidationFunctionResult<T, ZodValidationError>;
|
|
9
9
|
export interface ZodValidationErrorData extends ErrorData {
|
|
10
10
|
}
|
|
11
11
|
export declare class ZodValidationError extends AppError<ZodValidationErrorData> {
|
package/dist/zod/zod.util.js
CHANGED
|
@@ -17,7 +17,9 @@ export function zValidate(value, schema) {
|
|
|
17
17
|
throw err;
|
|
18
18
|
return data;
|
|
19
19
|
}
|
|
20
|
-
export function zSafeValidate(input, schema
|
|
20
|
+
export function zSafeValidate(input, schema
|
|
21
|
+
// inputName?: string,
|
|
22
|
+
) {
|
|
21
23
|
const r = schema.safeParse(input);
|
|
22
24
|
if (r.success) {
|
|
23
25
|
return [null, r.data];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/js-lib",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.64.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"tslib": "^2"
|
|
7
7
|
},
|
|
@@ -21,9 +21,10 @@
|
|
|
21
21
|
"@types/crypto-js": "^4",
|
|
22
22
|
"@types/node": "^25",
|
|
23
23
|
"@types/semver": "^7",
|
|
24
|
+
"@typescript/native-preview": "7.0.0-dev.20260201.1",
|
|
24
25
|
"crypto-js": "^4",
|
|
25
26
|
"dayjs": "^1",
|
|
26
|
-
"@naturalcycles/dev-lib": "
|
|
27
|
+
"@naturalcycles/dev-lib": "18.4.2"
|
|
27
28
|
},
|
|
28
29
|
"exports": {
|
|
29
30
|
".": "./dist/index.js",
|
package/src/array/sort.ts
CHANGED
|
@@ -1,33 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type Comparator,
|
|
4
|
-
type Mapper,
|
|
5
|
-
type SortDirection,
|
|
6
|
-
type SortOptions,
|
|
7
|
-
type StringMap,
|
|
8
|
-
} from '../types.js'
|
|
1
|
+
import { _stringMapValues } from '../types.js'
|
|
2
|
+
import type { Comparator, Mapper, SortDirection, SortOptions, StringMap } from '../types.js'
|
|
9
3
|
|
|
10
4
|
class Comparators {
|
|
11
5
|
/**
|
|
12
6
|
* Good for numbers.
|
|
13
7
|
*/
|
|
14
|
-
numericAsc(a: number, b: number): number {
|
|
8
|
+
numericAsc(this: void, a: number, b: number): number {
|
|
15
9
|
return a - b
|
|
16
10
|
}
|
|
17
11
|
|
|
18
|
-
numericDesc(a: number, b: number): number {
|
|
12
|
+
numericDesc(this: void, a: number, b: number): number {
|
|
19
13
|
return b - a
|
|
20
14
|
}
|
|
21
15
|
|
|
22
|
-
localeAsc(a: string, b: string): number {
|
|
16
|
+
localeAsc(this: void, a: string, b: string): number {
|
|
23
17
|
return a.localeCompare(b)
|
|
24
18
|
}
|
|
25
19
|
|
|
26
|
-
localeDesc(a: string, b: string): number {
|
|
20
|
+
localeDesc(this: void, a: string, b: string): number {
|
|
27
21
|
return -a.localeCompare(b)
|
|
28
22
|
}
|
|
29
23
|
|
|
30
24
|
by<T, COMPARE_TYPE extends string | number>(
|
|
25
|
+
this: void,
|
|
31
26
|
mapper: Mapper<T, COMPARE_TYPE>,
|
|
32
27
|
opt: ComparatorByOptions = {},
|
|
33
28
|
): Comparator<T> {
|
|
@@ -43,19 +38,19 @@ class Comparators {
|
|
|
43
38
|
}
|
|
44
39
|
}
|
|
45
40
|
|
|
46
|
-
updatedAsc(a: { updated: number }, b: { updated: number }): number {
|
|
41
|
+
updatedAsc(this: void, a: { updated: number }, b: { updated: number }): number {
|
|
47
42
|
return a.updated - b.updated
|
|
48
43
|
}
|
|
49
44
|
|
|
50
|
-
updatedDesc(a: { updated: number }, b: { updated: number }): number {
|
|
45
|
+
updatedDesc(this: void, a: { updated: number }, b: { updated: number }): number {
|
|
51
46
|
return b.updated - a.updated
|
|
52
47
|
}
|
|
53
48
|
|
|
54
|
-
createdAsc(a: { created: number }, b: { created: number }): number {
|
|
49
|
+
createdAsc(this: void, a: { created: number }, b: { created: number }): number {
|
|
55
50
|
return a.created - b.created
|
|
56
51
|
}
|
|
57
52
|
|
|
58
|
-
createdDesc(a: { created: number }, b: { created: number }): number {
|
|
53
|
+
createdDesc(this: void, a: { created: number }, b: { created: number }): number {
|
|
59
54
|
return b.created - a.created
|
|
60
55
|
}
|
|
61
56
|
}
|
|
@@ -17,7 +17,6 @@ export async function loadGTag(gtagId: string, enabled = true): Promise<void> {
|
|
|
17
17
|
|
|
18
18
|
globalThis.dataLayer ||= []
|
|
19
19
|
globalThis.gtag ||= function gtag() {
|
|
20
|
-
// biome-ignore lint/complexity/noArguments: ok
|
|
21
20
|
globalThis.dataLayer.push(arguments)
|
|
22
21
|
}
|
|
23
22
|
globalThis.gtag('js', new Date())
|
|
@@ -43,16 +42,16 @@ export async function loadGTM(gtmId: string, enabled = true): Promise<void> {
|
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
export function loadHotjar(hjid: number): void {
|
|
46
|
-
if (isServerSide())
|
|
45
|
+
if (isServerSide()) {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
47
48
|
|
|
48
49
|
/* eslint-disable */
|
|
49
|
-
//
|
|
50
|
-
;
|
|
50
|
+
// oxfmt-ignore
|
|
51
51
|
;((h: any, o, t, j, a?: any, r?: any) => {
|
|
52
52
|
h.hj =
|
|
53
53
|
h.hj ||
|
|
54
54
|
function hj() {
|
|
55
|
-
// biome-ignore lint/complexity/noArguments: ok
|
|
56
55
|
;(h.hj.q = h.hj.q || []).push(arguments)
|
|
57
56
|
}
|
|
58
57
|
h._hjSettings = { hjid, hjsv: 6 }
|
|
@@ -686,6 +686,18 @@ export class LocalTime {
|
|
|
686
686
|
// return s.slice(0, 10) + ' ' + s.slice(11, seconds ? 19 : 16)
|
|
687
687
|
}
|
|
688
688
|
|
|
689
|
+
/**
|
|
690
|
+
* Returns e.g: `1984-06-21T17:56:21Z`
|
|
691
|
+
*
|
|
692
|
+
* IsoDateTime "format" is ambiguous.
|
|
693
|
+
* Normally what we mean by it is `1984-06-21T17:56:21` (without Z).
|
|
694
|
+
* But sometimes you need Z.
|
|
695
|
+
* So, when you need Z - use this function.
|
|
696
|
+
*/
|
|
697
|
+
toISODateTimeWithZ(): IsoDateTime {
|
|
698
|
+
return (this.toISODateTime() + 'Z') as IsoDateTime
|
|
699
|
+
}
|
|
700
|
+
|
|
689
701
|
/**
|
|
690
702
|
* Returns e.g: `1984-06-21T17:56:21`
|
|
691
703
|
*/
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { ErrorMode } from '../error/errorMode.js'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type CommonLogLevel,
|
|
5
|
-
createCommonLoggerAtLevel,
|
|
6
|
-
} from '../log/commonLogger.js'
|
|
2
|
+
import { createCommonLoggerAtLevel } from '../log/commonLogger.js'
|
|
3
|
+
import type { CommonLogger, CommonLogLevel } from '../log/commonLogger.js'
|
|
7
4
|
import type { AsyncFunction, PositiveInteger } from '../types.js'
|
|
8
5
|
import type { DeferredPromise } from './pDefer.js'
|
|
9
6
|
import { pDefer } from './pDefer.js'
|
package/src/promise/pMap.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ErrorMode } from '../error/errorMode.js'
|
|
2
2
|
import type { CommonLogger } from '../log/commonLogger.js'
|
|
3
|
-
import {
|
|
3
|
+
import { END, SKIP } from '../types.js'
|
|
4
|
+
import type { AbortableAsyncMapper } from '../types.js'
|
|
4
5
|
|
|
5
6
|
export interface PMapOptions {
|
|
6
7
|
/**
|
package/src/promise/pQueue.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { ErrorMode } from '../error/errorMode.js'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
type CommonLogLevel,
|
|
5
|
-
createCommonLoggerAtLevel,
|
|
6
|
-
} from '../log/commonLogger.js'
|
|
2
|
+
import { createCommonLoggerAtLevel } from '../log/commonLogger.js'
|
|
3
|
+
import type { CommonLogger, CommonLogLevel } from '../log/commonLogger.js'
|
|
7
4
|
import type { AsyncFunction, PositiveInteger } from '../types.js'
|
|
8
5
|
import type { DeferredPromise } from './pDefer.js'
|
|
9
6
|
import { pDefer } from './pDefer.js'
|
package/src/promise/pTimeout.ts
CHANGED
|
@@ -73,7 +73,6 @@ export async function pTimeout<T>(fn: AnyAsyncFunction<T>, opt: PTimeoutOptions)
|
|
|
73
73
|
const { timeout, name = fn.name || 'pTimeout function', onTimeout } = opt
|
|
74
74
|
const fakeError = opt.fakeError || new Error('TimeoutError')
|
|
75
75
|
|
|
76
|
-
// biome-ignore lint/suspicious/noAsyncPromiseExecutor: ok
|
|
77
76
|
return await new Promise(async (resolve, reject) => {
|
|
78
77
|
// Prepare the timeout timer
|
|
79
78
|
const timer = setTimeout(() => {
|
|
@@ -15,8 +15,8 @@ import type { AppError } from '../error/error.util.js'
|
|
|
15
15
|
*
|
|
16
16
|
* @experimental
|
|
17
17
|
*/
|
|
18
|
-
export type ValidationFunction<
|
|
19
|
-
input:
|
|
18
|
+
export type ValidationFunction<OUT, ERR extends AppError> = (
|
|
19
|
+
input: unknown,
|
|
20
20
|
opt?: ValidationFunctionOptions,
|
|
21
21
|
) => ValidationFunctionResult<OUT, ERR>
|
|
22
22
|
|
package/src/zod/zod.util.ts
CHANGED
|
@@ -7,26 +7,26 @@ import type { ValidationFunction, ValidationFunctionResult } from '../validation
|
|
|
7
7
|
|
|
8
8
|
export function getZodValidationFunction<T>(
|
|
9
9
|
schema: ZodType<T>,
|
|
10
|
-
): ValidationFunction<T,
|
|
10
|
+
): ValidationFunction<T, ZodValidationError> {
|
|
11
11
|
return (input, opt) => {
|
|
12
12
|
_assert(!opt?.mutateInput, 'mutateInput=true is not yet supported with Zod')
|
|
13
13
|
return zSafeValidate(input, schema)
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function zIsValid<T>(value:
|
|
17
|
+
export function zIsValid<T>(value: unknown, schema: ZodType<T>): boolean {
|
|
18
18
|
const { success } = schema.safeParse(value)
|
|
19
19
|
return success
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export function zValidate<T>(value:
|
|
22
|
+
export function zValidate<T>(value: unknown, schema: ZodType<T>): T {
|
|
23
23
|
const [err, data] = zSafeValidate(value, schema)
|
|
24
24
|
if (err) throw err
|
|
25
25
|
return data
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export function zSafeValidate<T>(
|
|
29
|
-
input:
|
|
29
|
+
input: unknown,
|
|
30
30
|
schema: ZodType<T>,
|
|
31
31
|
// inputName?: string,
|
|
32
32
|
): ValidationFunctionResult<T, ZodValidationError> {
|
|
@@ -35,7 +35,7 @@ export function zSafeValidate<T>(
|
|
|
35
35
|
return [null, r.data]
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
return [new ZodValidationError(r.error, input, schema), r.data ?? input]
|
|
38
|
+
return [new ZodValidationError(r.error, input, schema), r.data ?? (input as T)]
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export interface ZodValidationErrorData extends ErrorData {}
|