@naturalcycles/js-lib 14.109.0 → 14.110.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/array.util.d.ts +2 -2
- package/dist/datetime/dateInterval.d.ts +2 -1
- package/dist/datetime/localDate.d.ts +1 -1
- package/dist/datetime/localTime.d.ts +3 -2
- package/dist/datetime/timeInterval.d.ts +4 -3
- package/dist/decorators/asyncMemo.decorator.d.ts +2 -2
- package/dist/decorators/debounce.d.ts +1 -1
- package/dist/decorators/debounce.decorator.d.ts +1 -1
- package/dist/decorators/decorator.util.d.ts +1 -1
- package/dist/decorators/logMethod.decorator.d.ts +1 -1
- package/dist/decorators/memo.decorator.d.ts +2 -2
- package/dist/decorators/memo.util.d.ts +1 -1
- package/dist/decorators/memoFn.d.ts +2 -2
- package/dist/decorators/memoFnAsync.d.ts +2 -2
- package/dist/decorators/memoSimple.decorator.d.ts +1 -1
- package/dist/decorators/retry.decorator.d.ts +1 -1
- package/dist/decorators/timeout.decorator.d.ts +1 -1
- package/dist/enum.util.d.ts +1 -1
- package/dist/error/app.error.d.ts +1 -1
- package/dist/error/assert.d.ts +1 -1
- package/dist/error/error.util.d.ts +4 -3
- package/dist/error/http.error.d.ts +1 -1
- package/dist/error/try.d.ts +1 -1
- package/dist/error/tryCatch.d.ts +2 -2
- package/dist/index.d.ts +20 -23
- package/dist/index.js +20 -26
- package/dist/is.util.d.ts +2 -2
- package/dist/json-schema/from-data/generateJsonSchemaFromData.d.ts +2 -2
- package/dist/json-schema/jsonSchema.cnst.d.ts +1 -1
- package/dist/json-schema/jsonSchema.model.d.ts +2 -2
- package/dist/json-schema/jsonSchema.util.d.ts +3 -2
- package/dist/json-schema/jsonSchemaBuilder.d.ts +2 -2
- package/dist/json-schema/jsonSchemas.d.ts +1 -1
- package/dist/lazy.d.ts +1 -1
- package/dist/object/object.util.d.ts +2 -2
- package/dist/object/sortObject.d.ts +1 -1
- package/dist/promise/pFilter.d.ts +1 -1
- package/dist/promise/pMap.d.ts +2 -1
- package/dist/promise/pQueue.d.ts +1 -1
- package/dist/promise/pRetry.d.ts +1 -1
- package/dist/promise/pTimeout.d.ts +2 -2
- package/dist/seq/seq.d.ts +2 -1
- package/dist/string/safeJsonStringify.d.ts +1 -1
- package/dist/string/stringifyAny.d.ts +1 -1
- package/dist/string/url.util.d.ts +1 -1
- package/dist/typeFest.d.ts +40 -3
- package/dist/types.d.ts +5 -13
- package/dist-esm/error/error.util.js +1 -1
- package/dist-esm/index.js +20 -12
- package/dist-esm/json-schema/from-data/generateJsonSchemaFromData.js +1 -1
- package/dist-esm/json-schema/jsonSchemaBuilder.js +1 -1
- package/dist-esm/seq/seq.js +1 -1
- package/package.json +2 -2
- package/src/array/array.util.ts +2 -2
- package/src/datetime/dateInterval.ts +2 -1
- package/src/datetime/localDate.ts +1 -1
- package/src/datetime/localTime.ts +3 -2
- package/src/datetime/timeInterval.ts +4 -3
- package/src/decorators/asyncMemo.decorator.ts +4 -3
- package/src/decorators/debounce.decorator.ts +2 -1
- package/src/decorators/debounce.ts +1 -1
- package/src/decorators/decorator.util.ts +1 -1
- package/src/decorators/logMethod.decorator.ts +2 -1
- package/src/decorators/memo.decorator.ts +4 -3
- package/src/decorators/memo.util.ts +1 -1
- package/src/decorators/memoFn.ts +3 -2
- package/src/decorators/memoFnAsync.ts +3 -2
- package/src/decorators/memoSimple.decorator.ts +3 -2
- package/src/decorators/retry.decorator.ts +2 -1
- package/src/decorators/timeout.decorator.ts +2 -1
- package/src/enum.util.ts +1 -1
- package/src/error/app.error.ts +1 -1
- package/src/error/assert.ts +2 -1
- package/src/error/error.util.ts +6 -6
- package/src/error/http.error.ts +1 -1
- package/src/error/try.ts +1 -1
- package/src/error/tryCatch.ts +3 -2
- package/src/index.ts +20 -244
- package/src/is.util.ts +2 -2
- package/src/json-schema/from-data/generateJsonSchemaFromData.ts +5 -4
- package/src/json-schema/jsonSchema.cnst.ts +1 -1
- package/src/json-schema/jsonSchema.model.ts +2 -2
- package/src/json-schema/jsonSchema.util.ts +3 -3
- package/src/json-schema/jsonSchemaBuilder.ts +3 -5
- package/src/json-schema/jsonSchemas.ts +1 -1
- package/src/lazy.ts +1 -1
- package/src/object/object.util.ts +2 -2
- package/src/object/sortObject.ts +2 -1
- package/src/promise/pFilter.ts +1 -1
- package/src/promise/pMap.ts +2 -1
- package/src/promise/pQueue.ts +3 -2
- package/src/promise/pRetry.ts +2 -1
- package/src/promise/pTimeout.ts +2 -2
- package/src/seq/seq.ts +2 -3
- package/src/string/safeJsonStringify.ts +1 -1
- package/src/string/stringifyAny.ts +1 -1
- package/src/string/url.util.ts +1 -1
- package/src/typeFest.ts +57 -7
- package/src/types.ts +8 -20
package/src/index.ts
CHANGED
|
@@ -2,18 +2,14 @@ export * from './array/array.util'
|
|
|
2
2
|
export * from './lazy'
|
|
3
3
|
export * from './string/url.util'
|
|
4
4
|
export * from './array/range'
|
|
5
|
-
|
|
6
|
-
PromiseDecoratorCfg,
|
|
7
|
-
PromiseDecoratorResp,
|
|
8
|
-
_createPromiseDecorator,
|
|
9
|
-
} from './decorators/createPromiseDecorator'
|
|
5
|
+
export * from './decorators/createPromiseDecorator'
|
|
10
6
|
export * from './decorators/debounce'
|
|
11
7
|
export * from './decorators/debounce.decorator'
|
|
12
8
|
export * from './decorators/decorator.util'
|
|
13
9
|
export * from './decorators/logMethod.decorator'
|
|
14
10
|
export * from './decorators/memo.decorator'
|
|
15
11
|
export * from './decorators/asyncMemo.decorator'
|
|
16
|
-
|
|
12
|
+
export * from './decorators/memo.util'
|
|
17
13
|
export * from './decorators/memoFn'
|
|
18
14
|
export * from './decorators/memoFnAsync'
|
|
19
15
|
export * from './decorators/retry.decorator'
|
|
@@ -21,46 +17,18 @@ export * from './decorators/timeout.decorator'
|
|
|
21
17
|
export * from './error/app.error'
|
|
22
18
|
export * from './error/assert'
|
|
23
19
|
export * from './enum.util'
|
|
24
|
-
|
|
25
|
-
Admin401ErrorData,
|
|
26
|
-
Admin403ErrorData,
|
|
27
|
-
ErrorData,
|
|
28
|
-
ErrorObject,
|
|
29
|
-
HttpErrorData,
|
|
30
|
-
HttpErrorResponse,
|
|
31
|
-
} from './error/error.model'
|
|
20
|
+
export * from './error/error.model'
|
|
32
21
|
export * from './error/error.util'
|
|
33
|
-
|
|
22
|
+
export * from './error/errorMode'
|
|
34
23
|
export * from './error/http.error'
|
|
35
24
|
export * from './error/try'
|
|
36
|
-
|
|
25
|
+
export * from './error/tryCatch'
|
|
37
26
|
export * from './json-schema/from-data/generateJsonSchemaFromData'
|
|
38
27
|
export * from './json-schema/jsonSchema.cnst'
|
|
39
|
-
|
|
40
|
-
JsonSchema,
|
|
41
|
-
JsonSchemaAllOf,
|
|
42
|
-
JsonSchemaAny,
|
|
43
|
-
JsonSchemaAnyOf,
|
|
44
|
-
JsonSchemaArray,
|
|
45
|
-
JsonSchemaBoolean,
|
|
46
|
-
JsonSchemaConst,
|
|
47
|
-
JsonSchemaEnum,
|
|
48
|
-
JsonSchemaNot,
|
|
49
|
-
JsonSchemaNull,
|
|
50
|
-
JsonSchemaNumber,
|
|
51
|
-
JsonSchemaRootObject,
|
|
52
|
-
JsonSchemaObject,
|
|
53
|
-
JsonSchemaOneOf,
|
|
54
|
-
JsonSchemaRef,
|
|
55
|
-
JsonSchemaString,
|
|
56
|
-
JsonSchemaTuple,
|
|
57
|
-
} from './json-schema/jsonSchema.model'
|
|
28
|
+
export * from './json-schema/jsonSchema.model'
|
|
58
29
|
export * from './json-schema/jsonSchema.util'
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
JsonSchemaAnyBuilder,
|
|
62
|
-
JsonSchemaBuilder,
|
|
63
|
-
} from './json-schema/jsonSchemaBuilder'
|
|
30
|
+
export * from './json-schema/jsonSchemaBuilder'
|
|
31
|
+
export * from './json-schema/jsonSchemaBuilder'
|
|
64
32
|
export * from './math/math.util'
|
|
65
33
|
export * from './math/sma'
|
|
66
34
|
export * from './number/createDeterministicRandom'
|
|
@@ -69,90 +37,31 @@ export * from './object/deepEquals'
|
|
|
69
37
|
export * from './object/object.util'
|
|
70
38
|
export * from './object/sortObject'
|
|
71
39
|
export * from './object/sortObjectDeep'
|
|
72
|
-
|
|
73
|
-
|
|
40
|
+
export * from './promise/AggregatedError'
|
|
41
|
+
export * from './promise/pDefer'
|
|
74
42
|
export * from './promise/pDelay'
|
|
75
43
|
export * from './promise/pFilter'
|
|
76
44
|
export * from './promise/pHang'
|
|
77
|
-
|
|
45
|
+
export * from './promise/pMap'
|
|
78
46
|
export * from './promise/pProps'
|
|
79
|
-
|
|
47
|
+
export * from './promise/pRetry'
|
|
80
48
|
export * from './promise/pState'
|
|
81
|
-
|
|
49
|
+
export * from './promise/pTimeout'
|
|
82
50
|
export * from './string/case'
|
|
83
51
|
export * from './string/json.util'
|
|
84
52
|
export * from './string/string.util'
|
|
85
53
|
export * from './string/readingTime'
|
|
86
54
|
export * from './string/escape'
|
|
87
55
|
export * from './string/pupa'
|
|
88
|
-
|
|
56
|
+
export * from './string/stringifyAny'
|
|
89
57
|
export * from './time/time.util'
|
|
90
58
|
export * from './is.util'
|
|
91
|
-
|
|
92
|
-
import {
|
|
93
|
-
Class,
|
|
94
|
-
ConditionalExcept,
|
|
95
|
-
ConditionalPick,
|
|
96
|
-
Merge,
|
|
97
|
-
Promisable,
|
|
98
|
-
ReadonlyDeep,
|
|
99
|
-
Simplify,
|
|
100
|
-
} from './typeFest'
|
|
101
|
-
import {
|
|
102
|
-
AsyncMapper,
|
|
103
|
-
AsyncPredicate,
|
|
104
|
-
BaseDBEntity,
|
|
105
|
-
CreatedUpdated,
|
|
106
|
-
CreatedUpdatedId,
|
|
107
|
-
ObjectWithId,
|
|
108
|
-
AnyObjectWithId,
|
|
109
|
-
Saved,
|
|
110
|
-
Unsaved,
|
|
111
|
-
UnsavedId,
|
|
112
|
-
BatchResult,
|
|
113
|
-
InstanceId,
|
|
114
|
-
IsoDate,
|
|
115
|
-
IsoDateString,
|
|
116
|
-
IsoDateTimeString,
|
|
117
|
-
KeyValueTuple,
|
|
118
|
-
Mapper,
|
|
119
|
-
ObjectMapper,
|
|
120
|
-
ObjectPredicate,
|
|
121
|
-
Predicate,
|
|
122
|
-
PromiseMap,
|
|
123
|
-
AnyObject,
|
|
124
|
-
AnyEnum,
|
|
125
|
-
NumberEnum,
|
|
126
|
-
StringEnum,
|
|
127
|
-
AnyFunction,
|
|
128
|
-
Reviver,
|
|
129
|
-
SavedDBEntity,
|
|
130
|
-
StringMap,
|
|
131
|
-
UnixTimestampNumber,
|
|
132
|
-
UnixTimestampMillisNumber,
|
|
133
|
-
UnixTimestamp,
|
|
134
|
-
Integer,
|
|
135
|
-
ValueOf,
|
|
136
|
-
ValuesOf,
|
|
137
|
-
AbortableMapper,
|
|
138
|
-
AbortableAsyncPredicate,
|
|
139
|
-
AbortableAsyncMapper,
|
|
140
|
-
AbortablePredicate,
|
|
141
|
-
NullishValue,
|
|
142
|
-
FalsyValue,
|
|
143
|
-
} from './types'
|
|
59
|
+
export * from './typeFest'
|
|
144
60
|
export * from './types'
|
|
145
61
|
export * from './unit/size.util'
|
|
146
62
|
import { is } from './vendor/is'
|
|
147
|
-
import {
|
|
148
|
-
CommonLogLevel,
|
|
149
|
-
CommonLogFunction,
|
|
150
|
-
CommonLogger,
|
|
151
|
-
CommonLogWithLevelFunction,
|
|
152
|
-
} from './log/commonLogger'
|
|
153
63
|
export * from './log/commonLogger'
|
|
154
64
|
export * from './string/safeJsonStringify'
|
|
155
|
-
import { PQueueCfg } from './promise/pQueue'
|
|
156
65
|
export * from './promise/pQueue'
|
|
157
66
|
export * from './seq/seq'
|
|
158
67
|
export * from './math/stack.util'
|
|
@@ -161,142 +70,9 @@ export * from './datetime/localDate'
|
|
|
161
70
|
export * from './datetime/localTime'
|
|
162
71
|
export * from './datetime/dateInterval'
|
|
163
72
|
export * from './datetime/timeInterval'
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
LocalDateUnitStrict,
|
|
169
|
-
Inclusiveness,
|
|
170
|
-
} from './datetime/localDate'
|
|
171
|
-
import {
|
|
172
|
-
LocalTimeConfig,
|
|
173
|
-
LocalTimeFormatter,
|
|
174
|
-
LocalTimeUnit,
|
|
175
|
-
LocalTimeComponents,
|
|
176
|
-
ISODayOfWeek,
|
|
177
|
-
} from './datetime/localTime'
|
|
178
|
-
import { DateIntervalConfig, DateIntervalString } from './datetime/dateInterval'
|
|
179
|
-
import { TimeIntervalConfig, TimeIntervalString } from './datetime/timeInterval'
|
|
180
|
-
|
|
181
|
-
export type {
|
|
182
|
-
DateIntervalConfig,
|
|
183
|
-
DateIntervalString,
|
|
184
|
-
TimeIntervalConfig,
|
|
185
|
-
TimeIntervalString,
|
|
186
|
-
LocalDateConfig,
|
|
187
|
-
LocalDateFormatter,
|
|
188
|
-
LocalDateUnit,
|
|
189
|
-
LocalDateUnitStrict,
|
|
190
|
-
Inclusiveness,
|
|
191
|
-
LocalTimeConfig,
|
|
192
|
-
LocalTimeFormatter,
|
|
193
|
-
LocalTimeUnit,
|
|
194
|
-
ISODayOfWeek,
|
|
195
|
-
LocalTimeComponents,
|
|
196
|
-
AbortableMapper,
|
|
197
|
-
AbortablePredicate,
|
|
198
|
-
AbortableAsyncPredicate,
|
|
199
|
-
AbortableAsyncMapper,
|
|
200
|
-
PQueueCfg,
|
|
201
|
-
MemoCache,
|
|
202
|
-
AsyncMemoCache,
|
|
203
|
-
PromiseDecoratorCfg,
|
|
204
|
-
PromiseDecoratorResp,
|
|
205
|
-
ErrorData,
|
|
206
|
-
ErrorObject,
|
|
207
|
-
HttpErrorData,
|
|
208
|
-
HttpErrorResponse,
|
|
209
|
-
Admin401ErrorData,
|
|
210
|
-
Admin403ErrorData,
|
|
211
|
-
StringMap,
|
|
212
|
-
PromiseMap,
|
|
213
|
-
AnyObject,
|
|
214
|
-
AnyEnum,
|
|
215
|
-
NumberEnum,
|
|
216
|
-
StringEnum,
|
|
217
|
-
AnyFunction,
|
|
218
|
-
ValuesOf,
|
|
219
|
-
ValueOf,
|
|
220
|
-
KeyValueTuple,
|
|
221
|
-
ObjectMapper,
|
|
222
|
-
ObjectPredicate,
|
|
223
|
-
InstanceId,
|
|
224
|
-
IsoDate,
|
|
225
|
-
IsoDateString,
|
|
226
|
-
IsoDateTimeString,
|
|
227
|
-
Reviver,
|
|
228
|
-
FalsyValue,
|
|
229
|
-
NullishValue,
|
|
230
|
-
PMapOptions,
|
|
231
|
-
Mapper,
|
|
232
|
-
AsyncMapper,
|
|
233
|
-
Predicate,
|
|
234
|
-
AsyncPredicate,
|
|
235
|
-
BatchResult,
|
|
236
|
-
DeferredPromise,
|
|
237
|
-
PRetryOptions,
|
|
238
|
-
PTimeoutOptions,
|
|
239
|
-
TryCatchOptions,
|
|
240
|
-
StringifyAnyOptions,
|
|
241
|
-
JsonStringifyFunction,
|
|
242
|
-
Merge,
|
|
243
|
-
ReadonlyDeep,
|
|
244
|
-
Promisable,
|
|
245
|
-
Simplify,
|
|
246
|
-
ConditionalPick,
|
|
247
|
-
ConditionalExcept,
|
|
248
|
-
Class,
|
|
249
|
-
UnixTimestampNumber,
|
|
250
|
-
UnixTimestampMillisNumber,
|
|
251
|
-
UnixTimestamp,
|
|
252
|
-
Integer,
|
|
253
|
-
BaseDBEntity,
|
|
254
|
-
SavedDBEntity,
|
|
255
|
-
Saved,
|
|
256
|
-
Unsaved,
|
|
257
|
-
UnsavedId,
|
|
258
|
-
CreatedUpdated,
|
|
259
|
-
CreatedUpdatedId,
|
|
260
|
-
ObjectWithId,
|
|
261
|
-
AnyObjectWithId,
|
|
262
|
-
JsonSchema,
|
|
263
|
-
JsonSchemaAny,
|
|
264
|
-
JsonSchemaOneOf,
|
|
265
|
-
JsonSchemaAllOf,
|
|
266
|
-
JsonSchemaAnyOf,
|
|
267
|
-
JsonSchemaNot,
|
|
268
|
-
JsonSchemaRef,
|
|
269
|
-
JsonSchemaConst,
|
|
270
|
-
JsonSchemaEnum,
|
|
271
|
-
JsonSchemaString,
|
|
272
|
-
JsonSchemaNumber,
|
|
273
|
-
JsonSchemaBoolean,
|
|
274
|
-
JsonSchemaNull,
|
|
275
|
-
JsonSchemaRootObject,
|
|
276
|
-
JsonSchemaObject,
|
|
277
|
-
JsonSchemaArray,
|
|
278
|
-
JsonSchemaTuple,
|
|
279
|
-
JsonSchemaBuilder,
|
|
280
|
-
CommonLogLevel,
|
|
281
|
-
CommonLogWithLevelFunction,
|
|
282
|
-
CommonLogFunction,
|
|
283
|
-
CommonLogger,
|
|
284
|
-
}
|
|
73
|
+
export * from './datetime/localDate'
|
|
74
|
+
export * from './datetime/localTime'
|
|
75
|
+
export * from './datetime/dateInterval'
|
|
76
|
+
export * from './datetime/timeInterval'
|
|
285
77
|
|
|
286
|
-
export {
|
|
287
|
-
is,
|
|
288
|
-
_createPromiseDecorator,
|
|
289
|
-
pMap,
|
|
290
|
-
ErrorMode,
|
|
291
|
-
pDefer,
|
|
292
|
-
AggregatedError,
|
|
293
|
-
pRetry,
|
|
294
|
-
pRetryFn,
|
|
295
|
-
pTimeout,
|
|
296
|
-
pTimeoutFn,
|
|
297
|
-
_tryCatch,
|
|
298
|
-
_TryCatch,
|
|
299
|
-
_stringifyAny,
|
|
300
|
-
jsonSchema,
|
|
301
|
-
JsonSchemaAnyBuilder,
|
|
302
|
-
}
|
|
78
|
+
export { is }
|
package/src/is.util.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Primitive } from './typeFest'
|
|
2
|
-
import { AnyObject, FalsyValue, NullishValue } from './types'
|
|
1
|
+
import type { Primitive } from './typeFest'
|
|
2
|
+
import type { AnyObject, FalsyValue, NullishValue } from './types'
|
|
3
3
|
|
|
4
4
|
type Nullish<T> = T extends NullishValue ? T : never
|
|
5
5
|
type Truthy<T> = T extends FalsyValue ? never : T
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
2
|
JsonSchema,
|
|
3
3
|
JsonSchemaArray,
|
|
4
4
|
JsonSchemaBoolean,
|
|
@@ -8,10 +8,9 @@ import {
|
|
|
8
8
|
JsonSchemaOneOf,
|
|
9
9
|
JsonSchemaString,
|
|
10
10
|
StringMap,
|
|
11
|
-
_stringMapEntries,
|
|
12
|
-
_uniq,
|
|
13
11
|
AnyObject,
|
|
14
12
|
} from '../..'
|
|
13
|
+
import { _stringMapEntries, _uniq } from '../..'
|
|
15
14
|
|
|
16
15
|
type PrimitiveType = 'undefined' | 'null' | 'boolean' | 'string' | 'number'
|
|
17
16
|
type Type = PrimitiveType | 'array' | 'object'
|
|
@@ -21,7 +20,9 @@ type Type = PrimitiveType | 'array' | 'object'
|
|
|
21
20
|
*
|
|
22
21
|
* `additionalProperties` is set to `true`, cause it's safer.
|
|
23
22
|
*/
|
|
24
|
-
export function generateJsonSchemaFromData<T =
|
|
23
|
+
export function generateJsonSchemaFromData<T extends AnyObject = AnyObject>(
|
|
24
|
+
rows: AnyObject[],
|
|
25
|
+
): JsonSchemaObject<T> {
|
|
25
26
|
return objectToJsonSchema(rows as any) as JsonSchemaObject<T>
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AnyObject, StringMap } from '../types'
|
|
1
|
+
import type { AnyObject, StringMap } from '../types'
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
4
4
|
export type JsonSchema<T = unknown> =
|
|
@@ -14,7 +14,7 @@ export type JsonSchema<T = unknown> =
|
|
|
14
14
|
| JsonSchemaNumber
|
|
15
15
|
| JsonSchemaBoolean
|
|
16
16
|
| JsonSchemaNull
|
|
17
|
-
| JsonSchemaObject
|
|
17
|
+
| JsonSchemaObject
|
|
18
18
|
| JsonSchemaArray<T>
|
|
19
19
|
| JsonSchemaTuple<T>
|
|
20
20
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { _uniq } from '../index'
|
|
1
|
+
import { _uniq, AnyObject } from '../index'
|
|
2
2
|
import { _filterNullishValues } from '../object/object.util'
|
|
3
|
-
import { JsonSchemaObject } from './jsonSchema.model'
|
|
3
|
+
import type { JsonSchemaObject } from './jsonSchema.model'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Merges s2 into s1 (mutates s1) and returns s1.
|
|
7
7
|
* Does not mutate s2.
|
|
8
8
|
* API similar to Object.assign(s1, s2)
|
|
9
9
|
*/
|
|
10
|
-
export function mergeJsonSchemaObjects<T1, T2>(
|
|
10
|
+
export function mergeJsonSchemaObjects<T1 extends AnyObject, T2 extends AnyObject>(
|
|
11
11
|
s1: JsonSchemaObject<T1>,
|
|
12
12
|
s2: JsonSchemaObject<T2>,
|
|
13
13
|
): JsonSchemaObject<T1 & T2> {
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { _uniq } from '../array/array.util'
|
|
2
|
-
import {
|
|
2
|
+
import type {
|
|
3
3
|
BaseDBEntity,
|
|
4
4
|
JsonSchemaAllOf,
|
|
5
5
|
JsonSchemaArray,
|
|
6
6
|
JsonSchemaOneOf,
|
|
7
7
|
JsonSchemaTuple,
|
|
8
|
-
mergeJsonSchemaObjects,
|
|
9
8
|
SavedDBEntity,
|
|
10
|
-
_deepCopy,
|
|
11
|
-
_sortObject,
|
|
12
9
|
AnyObject,
|
|
13
10
|
} from '../index'
|
|
11
|
+
import { mergeJsonSchemaObjects, _deepCopy, _sortObject } from '../index'
|
|
14
12
|
import { JSON_SCHEMA_ORDER } from './jsonSchema.cnst'
|
|
15
|
-
import {
|
|
13
|
+
import type {
|
|
16
14
|
JsonSchema,
|
|
17
15
|
JsonSchemaAny,
|
|
18
16
|
JsonSchemaBoolean,
|
package/src/lazy.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _isEmpty, _isObject } from '../is.util'
|
|
2
|
-
import { PropertyPath } from '../lodash.types'
|
|
3
|
-
import { AnyObject, ObjectMapper, ObjectPredicate, StringMap, ValueOf } from '../types'
|
|
2
|
+
import type { PropertyPath } from '../lodash.types'
|
|
3
|
+
import type { AnyObject, ObjectMapper, ObjectPredicate, StringMap, ValueOf } from '../types'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Returns clone of `obj` with only `props` preserved.
|
package/src/object/sortObject.ts
CHANGED
package/src/promise/pFilter.ts
CHANGED
package/src/promise/pMap.ts
CHANGED
|
@@ -7,7 +7,8 @@ Improvements:
|
|
|
7
7
|
- Compatible with pProps (that had typings issues)
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { AbortableAsyncMapper
|
|
10
|
+
import type { AbortableAsyncMapper } from '..'
|
|
11
|
+
import { END, ErrorMode, SKIP } from '..'
|
|
11
12
|
import { AggregatedError } from './AggregatedError'
|
|
12
13
|
|
|
13
14
|
export interface PMapOptions {
|
package/src/promise/pQueue.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ErrorMode } from '../error/errorMode'
|
|
2
|
-
import { CommonLogger } from '../log/commonLogger'
|
|
3
|
-
import { DeferredPromise
|
|
2
|
+
import type { CommonLogger } from '../log/commonLogger'
|
|
3
|
+
import type { DeferredPromise } from './pDefer'
|
|
4
|
+
import { pDefer } from './pDefer'
|
|
4
5
|
|
|
5
6
|
export interface PQueueCfg {
|
|
6
7
|
concurrency: number
|
package/src/promise/pRetry.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AnyFunction, AppError, CommonLogger, ErrorData } from '..'
|
|
2
|
+
import { _since, _stringifyAny } from '..'
|
|
2
3
|
import { TimeoutError } from './pTimeout'
|
|
3
4
|
|
|
4
5
|
export interface PRetryOptions {
|
package/src/promise/pTimeout.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AppError } from '../error/app.error'
|
|
2
|
-
import { ErrorData } from '../error/error.model'
|
|
3
|
-
import { AnyFunction } from '../types'
|
|
2
|
+
import type { ErrorData } from '../error/error.model'
|
|
3
|
+
import type { AnyFunction } from '../types'
|
|
4
4
|
|
|
5
5
|
export class TimeoutError extends AppError {}
|
|
6
6
|
|
package/src/seq/seq.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _isErrorObject, _isHttpErrorObject, _isHttpErrorResponse } from '../error/error.util'
|
|
2
|
-
import { Reviver } from '../types'
|
|
2
|
+
import type { Reviver } from '../types'
|
|
3
3
|
import { _jsonParseIfPossible } from './json.util'
|
|
4
4
|
import { _safeJsonStringify } from './safeJsonStringify'
|
|
5
5
|
|
package/src/string/url.util.ts
CHANGED
package/src/typeFest.ts
CHANGED
|
@@ -12,6 +12,27 @@ export type Primitive = null | undefined | string | number | boolean | symbol |
|
|
|
12
12
|
*/
|
|
13
13
|
export type Simplify<T> = { [KeyType in keyof T]: T[KeyType] }
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
Returns a boolean for whether the two given types are equal.
|
|
17
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
18
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
19
|
+
*/
|
|
20
|
+
export type IsEqual<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2
|
|
21
|
+
? true
|
|
22
|
+
: false
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Filter out keys from an object.
|
|
26
|
+
* Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
27
|
+
* Returns `never` if `Key` extends `Exclude`.
|
|
28
|
+
* Returns `Key` otherwise.
|
|
29
|
+
*/
|
|
30
|
+
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true
|
|
31
|
+
? never
|
|
32
|
+
: KeyType extends ExcludeType
|
|
33
|
+
? never
|
|
34
|
+
: KeyType
|
|
35
|
+
|
|
15
36
|
/**
|
|
16
37
|
Create a type from an object type without certain keys.
|
|
17
38
|
|
|
@@ -35,10 +56,9 @@ export type Simplify<T> = { [KeyType in keyof T]: T[KeyType] }
|
|
|
35
56
|
|
|
36
57
|
@category Utilities
|
|
37
58
|
*/
|
|
38
|
-
export type Except<ObjectType, KeysType extends keyof ObjectType> =
|
|
39
|
-
ObjectType,
|
|
40
|
-
|
|
41
|
-
>
|
|
59
|
+
export type Except<ObjectType, KeysType extends keyof ObjectType> = {
|
|
60
|
+
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType]
|
|
61
|
+
}
|
|
42
62
|
|
|
43
63
|
/**
|
|
44
64
|
Convert `object`s, `Map`s, `Set`s, and `Array`s and all of their keys/elements into immutable structures recursively.
|
|
@@ -99,8 +119,32 @@ type ReadonlyObjectDeep<ObjectType extends object> = {
|
|
|
99
119
|
readonly [KeyType in keyof ObjectType]: ReadonlyDeep<ObjectType[KeyType]>
|
|
100
120
|
}
|
|
101
121
|
|
|
102
|
-
|
|
103
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
124
|
+
* This is the counterpart of `OmitIndexSignature`.
|
|
125
|
+
* When you use a type that will iterate through an object that has indexed keys and explicitly defined keys you end up with a type where only the indexed keys are kept. This is because `keyof` of an indexed type always returns `string | number | symbol`, because every key is possible in that object. With this type, you can save the indexed keys and reinject them later, like in the second example below.
|
|
126
|
+
*/
|
|
127
|
+
export type PickIndexSignature<ObjectType> = {
|
|
128
|
+
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
|
129
|
+
? KeyType
|
|
130
|
+
: never]: ObjectType[KeyType]
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
135
|
+
* This is the counterpart of `PickIndexSignature`.
|
|
136
|
+
* Use-cases:
|
|
137
|
+
* - Remove overly permissive signatures from third-party types.
|
|
138
|
+
*
|
|
139
|
+
* This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
140
|
+
* It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
|
|
141
|
+
* (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
142
|
+
*/
|
|
143
|
+
export type OmitIndexSignature<ObjectType> = {
|
|
144
|
+
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
|
145
|
+
? never
|
|
146
|
+
: KeyType]: ObjectType[KeyType]
|
|
147
|
+
}
|
|
104
148
|
|
|
105
149
|
/**
|
|
106
150
|
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
@@ -123,7 +167,13 @@ type Merge_<FirstType, SecondType> = Except<FirstType, Extract<keyof FirstType,
|
|
|
123
167
|
|
|
124
168
|
@category Utilities
|
|
125
169
|
*/
|
|
126
|
-
export type Merge<
|
|
170
|
+
export type Merge<Destination, Source> = {
|
|
171
|
+
[Key in keyof OmitIndexSignature<Destination & Source>]: Key extends keyof Source
|
|
172
|
+
? Source[Key]
|
|
173
|
+
: Key extends keyof Destination
|
|
174
|
+
? Destination[Key]
|
|
175
|
+
: never
|
|
176
|
+
} & PickIndexSignature<Destination & Source>
|
|
127
177
|
|
|
128
178
|
/**
|
|
129
179
|
Create a type that represents either the value or the value wrapped in `PromiseLike`.
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Promisable } from './typeFest'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Map from String to String (or <T>).
|
|
@@ -9,15 +9,6 @@ export interface StringMap<T = string> {
|
|
|
9
9
|
[k: string | number]: T | undefined
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Object to be passed to pProps to resolve all promises into properties.
|
|
14
|
-
*
|
|
15
|
-
* Alternative: Record<String, Promise<any>>
|
|
16
|
-
*/
|
|
17
|
-
export interface PromiseMap {
|
|
18
|
-
[prop: string]: Promise<any> | undefined
|
|
19
|
-
}
|
|
20
|
-
|
|
21
12
|
/**
|
|
22
13
|
* Convenience shorthand for `Record<string, any>`.
|
|
23
14
|
* Because `object` type is not safe/recommended to be used (e.g discouraged by eslint-typescript due to: https://github.com/microsoft/TypeScript/issues/21732)
|
|
@@ -71,18 +62,15 @@ export interface SavedDBEntity<ID extends string | number = string> {
|
|
|
71
62
|
*/
|
|
72
63
|
export type BaseDBEntity<ID extends string | number = string> = Partial<SavedDBEntity<ID>>
|
|
73
64
|
|
|
74
|
-
export type Saved<T extends Partial<ObjectWithId>> =
|
|
75
|
-
|
|
76
|
-
SavedDBEntity<
|
|
77
|
-
>
|
|
65
|
+
// export type Saved<T extends Partial<ObjectWithId>> = Omit<T, 'id' | 'created' | 'updated'> & SavedDBEntity<NonNullable<T['id']>>
|
|
66
|
+
export type Saved<T extends Partial<ObjectWithId>> = Omit<T, 'id' | 'created' | 'updated'> &
|
|
67
|
+
SavedDBEntity<NonNullable<T['id']>>
|
|
78
68
|
|
|
79
|
-
export type Unsaved<T extends Partial<ObjectWithId>> =
|
|
80
|
-
T
|
|
81
|
-
BaseDBEntity<Exclude<T['id'], undefined>>
|
|
82
|
-
>
|
|
69
|
+
export type Unsaved<T extends Partial<ObjectWithId>> = Omit<T, 'id' | 'created' | 'updated'> &
|
|
70
|
+
BaseDBEntity<NonNullable<T['id']>>
|
|
83
71
|
|
|
84
|
-
export type UnsavedId<T extends Partial<ObjectWithId>> =
|
|
85
|
-
id
|
|
72
|
+
export type UnsavedId<T extends Partial<ObjectWithId>> = Omit<T, 'id'> & {
|
|
73
|
+
id?: T['id']
|
|
86
74
|
}
|
|
87
75
|
|
|
88
76
|
/**
|