@revolugo/common 6.9.6-beta.7 → 6.9.6
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/package.json +7 -12
- package/src/cancellation-policies.test.ts +9 -12
- package/src/cancellation-policies.ts +26 -31
- package/src/constants/countries.ts +2515 -0
- package/src/constants/currencies.ts +1812 -0
- package/src/constants/environment.ts +0 -1
- package/src/constants/hotel-offers.ts +0 -2
- package/src/constants/hotel.ts +0 -3
- package/src/constants/locales.ts +0 -6
- package/src/constants/measurement.ts +0 -1
- package/src/constants/time.ts +0 -1
- package/src/models/paginated-queries.ts +0 -1
- package/src/types/country.ts +1 -1
- package/src/types/index.ts +0 -1
- package/src/utils/array-tools.ts +2 -3
- package/src/utils/case-transformers.ts +0 -1
- package/src/utils/colors.ts +4 -4
- package/src/utils/countries.ts +4 -0
- package/src/utils/currency.ts +18 -30
- package/src/utils/dates.ts +10 -6
- package/src/utils/debounce.ts +2 -2
- package/src/utils/find-unique-keys.ts +2 -2
- package/src/utils/get-guest-count.ts +0 -1
- package/src/utils/index.ts +1 -1
- package/src/utils/lang-default-fallbacks.ts +1 -1
- package/src/utils/math.ts +3 -3
- package/src/utils/numbers.ts +7 -8
- package/src/utils/object-tools.ts +2 -60
- package/src/utils/poller.ts +0 -1
- package/src/utils/strings.ts +2 -5
- package/src/utils/validators.ts +0 -1
- package/src/countries/constants.ts +0 -2518
- package/src/countries/index.ts +0 -7
- package/src/currencies/index.ts +0 -1817
- package/src/types/elements/amenity.ts +0 -266
- package/src/types/elements/bed.ts +0 -20
- package/src/types/elements/booking-policy.ts +0 -80
- package/src/types/elements/booking.ts +0 -236
- package/src/types/elements/cancellation-policy.ts +0 -20
- package/src/types/elements/contact-person.ts +0 -158
- package/src/types/elements/currency.ts +0 -3
- package/src/types/elements/event-metadata.ts +0 -38
- package/src/types/elements/event.ts +0 -14
- package/src/types/elements/hotel-image.ts +0 -44
- package/src/types/elements/hotel-images.ts +0 -47
- package/src/types/elements/hotel-offer-request.ts +0 -82
- package/src/types/elements/hotel-offer.ts +0 -200
- package/src/types/elements/hotel-review-rating.ts +0 -14
- package/src/types/elements/hotel-room-offer-package-type.ts +0 -8
- package/src/types/elements/hotel-room-offer-request.ts +0 -77
- package/src/types/elements/hotel-room-offer-type.ts +0 -6
- package/src/types/elements/hotel-room-offer.ts +0 -192
- package/src/types/elements/hotel-room.ts +0 -102
- package/src/types/elements/hotel-rooming-list.ts +0 -49
- package/src/types/elements/hotel.ts +0 -184
- package/src/types/elements/index.ts +0 -22
- package/src/types/elements/invoice.ts +0 -21
- package/src/types/elements/payment-method.ts +0 -159
- package/src/types/elements/source-market.ts +0 -247
- package/src/types/elements/tag.ts +0 -32
- package/src/types/elements/tax.ts +0 -52
- package/src/types/elements/travel-times.ts +0 -45
- package/src/utils/random.ts +0 -12
|
@@ -39,7 +39,6 @@ export enum BookingEnvironment {
|
|
|
39
39
|
Development = 'development',
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
/* @__PURE__ */
|
|
43
42
|
export const BOOKING_API_URLS = {
|
|
44
43
|
[Environment.Production]: 'https://booking-api.revolugo.com',
|
|
45
44
|
[Environment.Sandbox]: 'https://booking-api.sandbox.revolugo.com',
|
package/src/constants/hotel.ts
CHANGED
package/src/constants/locales.ts
CHANGED
|
@@ -29,7 +29,6 @@ export function langFromString(langStr: string): Lang | undefined {
|
|
|
29
29
|
}
|
|
30
30
|
/* eslint-enable */
|
|
31
31
|
|
|
32
|
-
/* @__PURE__ */
|
|
33
32
|
export const LANG_TO_LOCALE: Record<Lang, Locale> = {
|
|
34
33
|
[Lang.EN]: Locale.en_US,
|
|
35
34
|
[Lang.FR]: Locale.fr_FR,
|
|
@@ -40,7 +39,6 @@ export const LANG_TO_LOCALE: Record<Lang, Locale> = {
|
|
|
40
39
|
[Lang.PT]: Locale.en_US,
|
|
41
40
|
}
|
|
42
41
|
|
|
43
|
-
/* @__PURE__ */
|
|
44
42
|
export const LOCALE_TO_LANG = {
|
|
45
43
|
[Locale.de_DE]: Lang.DE,
|
|
46
44
|
[Locale.en_US]: Lang.EN,
|
|
@@ -51,7 +49,6 @@ export const LOCALE_TO_LANG = {
|
|
|
51
49
|
[Locale.pt_PT]: Lang.PT,
|
|
52
50
|
}
|
|
53
51
|
|
|
54
|
-
/* @__PURE__ */
|
|
55
52
|
export const LOCALES = {
|
|
56
53
|
[Locale.en_US]: {
|
|
57
54
|
code: Locale.en_US,
|
|
@@ -104,9 +101,6 @@ export const LOCALES = {
|
|
|
104
101
|
},
|
|
105
102
|
}
|
|
106
103
|
|
|
107
|
-
/* @__PURE__ */
|
|
108
104
|
export const DATE_STRING_FORMAT = 'YYYY-MM-DD'
|
|
109
|
-
/* @__PURE__ */
|
|
110
105
|
export const FR_DATE_STRING_FORMAT = 'DD-MM-YYYY'
|
|
111
|
-
/* @__PURE__ */
|
|
112
106
|
export const DEFAULT_LOCALE = Locale.fr_FR
|
package/src/constants/time.ts
CHANGED
package/src/types/country.ts
CHANGED
package/src/types/index.ts
CHANGED
package/src/utils/array-tools.ts
CHANGED
|
@@ -6,9 +6,8 @@ export function chunk<T>(array: T[], size: number): T[][] {
|
|
|
6
6
|
return chunks
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
}
|
|
9
|
+
export const getRandomElementFromArray = <T>(array: readonly T[]): T =>
|
|
10
|
+
array[Math.floor(Math.random() * array.length)]
|
|
12
11
|
|
|
13
12
|
export function shuffleArray<T>(array: T[]): T[] {
|
|
14
13
|
const shuffled = [...array]
|
package/src/utils/colors.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { generateNumbersFromStr } from './numbers.ts'
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export const generateRandomColorFromString = (
|
|
4
4
|
str: string,
|
|
5
5
|
existingColors: string[],
|
|
6
|
-
): string {
|
|
6
|
+
): string => {
|
|
7
7
|
const [num1, num2] = generateNumbersFromStr(str)
|
|
8
8
|
// adjust this value to control how close the generated color is to the existing colors
|
|
9
9
|
const hueRange = 5
|
|
@@ -20,7 +20,7 @@ export function generateRandomColorFromString(
|
|
|
20
20
|
return newColor
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
export
|
|
23
|
+
export const hexToRgba = (hex: string, opacity: number): string => {
|
|
24
24
|
// Copy the value of 'hex' into a local variable without modifying the original parameter
|
|
25
25
|
let hexWithoutHash = hex
|
|
26
26
|
|
|
@@ -44,7 +44,7 @@ export function hexToRgba(hex: string, opacity: number): string {
|
|
|
44
44
|
const barColors = ['#006EFF', '#FF9800', '#9C27B0', '#F44336', '#4CAF50']
|
|
45
45
|
const contractIdToColors = new Map<string, string>()
|
|
46
46
|
|
|
47
|
-
export
|
|
47
|
+
export const getRangeColor = (id: string): string => {
|
|
48
48
|
if (!contractIdToColors.has(id)) {
|
|
49
49
|
contractIdToColors.set(id, generateRandomColorFromString(id, barColors))
|
|
50
50
|
}
|
package/src/utils/currency.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { CURRENCIES_MAP } from '../
|
|
1
|
+
import { CURRENCIES_MAP, type Currency } from '../constants/index.ts'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function getCurrencySymbol(currency: Currency): string {
|
|
3
|
+
export const getCurrencySymbol = (currency: Currency): string => {
|
|
6
4
|
const symbol = CURRENCIES_MAP[currency]?.symbol
|
|
7
5
|
|
|
8
6
|
if (!symbol) {
|
|
@@ -12,19 +10,16 @@ export function getCurrencySymbol(currency: Currency): string {
|
|
|
12
10
|
return symbol
|
|
13
11
|
}
|
|
14
12
|
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
(CURRENCIES_MAP[currency] && CURRENCIES_MAP[currency].zeroDecimal) || false
|
|
18
|
-
)
|
|
19
|
-
}
|
|
13
|
+
export const isZeroDecimal = (currency: Currency): boolean =>
|
|
14
|
+
(CURRENCIES_MAP[currency] && CURRENCIES_MAP[currency].zeroDecimal) || false
|
|
20
15
|
|
|
21
|
-
export
|
|
16
|
+
export const normalizeAmount = ({
|
|
22
17
|
amount,
|
|
23
18
|
currency,
|
|
24
19
|
}: {
|
|
25
20
|
amount: number
|
|
26
21
|
currency: Currency
|
|
27
|
-
}): number {
|
|
22
|
+
}): number => {
|
|
28
23
|
if (isZeroDecimal(currency)) {
|
|
29
24
|
return amount
|
|
30
25
|
}
|
|
@@ -32,13 +27,13 @@ export function normalizeAmount({
|
|
|
32
27
|
return amount * 100
|
|
33
28
|
}
|
|
34
29
|
|
|
35
|
-
export
|
|
30
|
+
export const denormalizeAmount = ({
|
|
36
31
|
amount,
|
|
37
32
|
currency,
|
|
38
33
|
}: {
|
|
39
34
|
amount: number
|
|
40
35
|
currency: Currency
|
|
41
|
-
}): number {
|
|
36
|
+
}): number => {
|
|
42
37
|
if (isZeroDecimal(currency)) {
|
|
43
38
|
return amount
|
|
44
39
|
}
|
|
@@ -46,17 +41,17 @@ export function denormalizeAmount({
|
|
|
46
41
|
return amount / 100
|
|
47
42
|
}
|
|
48
43
|
|
|
49
|
-
export
|
|
44
|
+
export const formatAmount = ({
|
|
50
45
|
amount,
|
|
51
46
|
currency,
|
|
52
47
|
locale = 'en',
|
|
53
|
-
space = '',
|
|
48
|
+
space = ' ',
|
|
54
49
|
}: {
|
|
55
50
|
amount: number
|
|
56
51
|
currency: string
|
|
57
52
|
locale?: string
|
|
58
53
|
space?: string
|
|
59
|
-
}): string {
|
|
54
|
+
}): string => {
|
|
60
55
|
const fractionDigits = amount.toFixed(2).endsWith('.00') ? 0 : 2
|
|
61
56
|
|
|
62
57
|
return (
|
|
@@ -75,7 +70,6 @@ export function formatAmount({
|
|
|
75
70
|
)
|
|
76
71
|
}
|
|
77
72
|
|
|
78
|
-
/* @__PURE__ */
|
|
79
73
|
export class MoneyCalculator {
|
|
80
74
|
private amount: number
|
|
81
75
|
private currency: Currency
|
|
@@ -148,12 +142,6 @@ export class MoneyCalculator {
|
|
|
148
142
|
return this
|
|
149
143
|
}
|
|
150
144
|
|
|
151
|
-
public round(): this {
|
|
152
|
-
this.amount = Math.round(this.amount)
|
|
153
|
-
|
|
154
|
-
return this
|
|
155
|
-
}
|
|
156
|
-
|
|
157
145
|
public format(locale?: string, space?: string): string {
|
|
158
146
|
return formatAmount({
|
|
159
147
|
amount: this.amount,
|
|
@@ -178,16 +166,16 @@ export class MoneyCalculator {
|
|
|
178
166
|
return this
|
|
179
167
|
}
|
|
180
168
|
|
|
181
|
-
const
|
|
169
|
+
const { isNormalized } = this
|
|
182
170
|
|
|
183
|
-
if (
|
|
171
|
+
if (isNormalized) {
|
|
184
172
|
this.denormalize()
|
|
185
173
|
}
|
|
186
174
|
|
|
187
175
|
this.amount *= exchangeRate
|
|
188
176
|
this.currency = currency
|
|
189
177
|
|
|
190
|
-
if (
|
|
178
|
+
if (isNormalized) {
|
|
191
179
|
this.normalize()
|
|
192
180
|
}
|
|
193
181
|
|
|
@@ -195,13 +183,13 @@ export class MoneyCalculator {
|
|
|
195
183
|
}
|
|
196
184
|
}
|
|
197
185
|
|
|
198
|
-
export
|
|
186
|
+
export const ceilNormalizedAmount = ({
|
|
199
187
|
amount,
|
|
200
188
|
currency,
|
|
201
189
|
}: {
|
|
202
190
|
amount: number
|
|
203
191
|
currency: Currency
|
|
204
|
-
}): number {
|
|
192
|
+
}): number => {
|
|
205
193
|
const denormalizedAmount = denormalizeAmount({
|
|
206
194
|
amount,
|
|
207
195
|
currency,
|
|
@@ -213,13 +201,13 @@ export function ceilNormalizedAmount({
|
|
|
213
201
|
})
|
|
214
202
|
}
|
|
215
203
|
|
|
216
|
-
export
|
|
204
|
+
export const floorNormalizedAmount = ({
|
|
217
205
|
amount,
|
|
218
206
|
currency,
|
|
219
207
|
}: {
|
|
220
208
|
amount: number
|
|
221
209
|
currency: Currency
|
|
222
|
-
}): number {
|
|
210
|
+
}): number => {
|
|
223
211
|
const denormalizedAmount = denormalizeAmount({
|
|
224
212
|
amount,
|
|
225
213
|
currency,
|
package/src/utils/dates.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { uniq } from 'lodash-es'
|
|
2
|
+
|
|
1
3
|
import { DATE_STRING_FORMAT } from '../constants/index.ts'
|
|
2
4
|
|
|
3
5
|
import { dayjs } from './dayjs.ts'
|
|
@@ -18,11 +20,11 @@ export function sortDates(dates: string[]): string[] {
|
|
|
18
20
|
return validDates.sort((a, b) => (dayjs(a).isAfter(dayjs(b), 'day') ? 1 : -1))
|
|
19
21
|
}
|
|
20
22
|
|
|
21
|
-
export
|
|
23
|
+
export const getDateRange = (
|
|
22
24
|
start: Date | string,
|
|
23
25
|
end: Date | string,
|
|
24
26
|
format: string = DATE_STRING_FORMAT,
|
|
25
|
-
): string[] {
|
|
27
|
+
): string[] => {
|
|
26
28
|
const dates: string[] = []
|
|
27
29
|
let current = dayjs(start)
|
|
28
30
|
|
|
@@ -39,7 +41,7 @@ export function sanitizeDateRange(
|
|
|
39
41
|
dateA: string,
|
|
40
42
|
dateB: string,
|
|
41
43
|
): [string, string] {
|
|
42
|
-
const sortedDates =
|
|
44
|
+
const sortedDates = uniq(sortDates([dateA, dateB]))
|
|
43
45
|
|
|
44
46
|
if (sortedDates.length === 2) {
|
|
45
47
|
return sortedDates as [string, string]
|
|
@@ -78,9 +80,11 @@ export function generateDates(
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
const totalDays = end.diff(start, 'day') + 1
|
|
81
|
-
const dates = Array
|
|
82
|
-
|
|
83
|
-
)
|
|
83
|
+
const dates = new Array<Date>(totalDays)
|
|
84
|
+
|
|
85
|
+
for (let i = 0; i < totalDays; i++) {
|
|
86
|
+
dates[i] = start.add(i, 'day').toDate()
|
|
87
|
+
}
|
|
84
88
|
|
|
85
89
|
return dates
|
|
86
90
|
}
|
package/src/utils/debounce.ts
CHANGED
|
@@ -46,7 +46,7 @@ export function debounce<Args extends any[], F extends (...args: Args) => any>(
|
|
|
46
46
|
return waitMilliseconds
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
function debouncedFunction(
|
|
49
|
+
const debouncedFunction = function debouncedFunction(
|
|
50
50
|
this: ThisParameterType<F>,
|
|
51
51
|
...args: Parameters<F>
|
|
52
52
|
) {
|
|
@@ -54,7 +54,7 @@ export function debounce<Args extends any[], F extends (...args: Args) => any>(
|
|
|
54
54
|
const context = this
|
|
55
55
|
// eslint-disable-next-line consistent-return
|
|
56
56
|
return new Promise<Awaited<ReturnType<F>>>((resolve, reject) => {
|
|
57
|
-
function invokeFunction() {
|
|
57
|
+
const invokeFunction = function invokeFunction() {
|
|
58
58
|
timeoutId = undefined
|
|
59
59
|
lastInvokeTime = Date.now()
|
|
60
60
|
if (!isImmediate) {
|
package/src/utils/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './add-classes.ts'
|
|
|
2
2
|
export * from './array-tools.ts'
|
|
3
3
|
export * from './case-transformers.ts'
|
|
4
4
|
export * from './colors.ts'
|
|
5
|
+
export * from './countries.ts'
|
|
5
6
|
export * from './currency.ts'
|
|
6
7
|
export * from './dates.ts'
|
|
7
8
|
export * from './dayjs.ts'
|
|
@@ -17,7 +18,6 @@ export * from './numbers.ts'
|
|
|
17
18
|
export * from './object-tools.ts'
|
|
18
19
|
export * from './poller.ts'
|
|
19
20
|
export * from './promise-tools.ts'
|
|
20
|
-
export * from './random.ts'
|
|
21
21
|
export * from './range.ts'
|
|
22
22
|
export * from './strings.ts'
|
|
23
23
|
export * from './sum.ts'
|
|
@@ -2,7 +2,7 @@ import { LOCALE_TO_LANG, Locale } from '../constants/locales.ts'
|
|
|
2
2
|
|
|
3
3
|
import type { Lang } from '../constants/locales.ts'
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export const langDefaultFallbacks = (lang?: Locale): Lang[] => {
|
|
6
6
|
if (!lang || lang === Locale.en_US) {
|
|
7
7
|
return [LOCALE_TO_LANG[Locale.en_US]]
|
|
8
8
|
}
|
package/src/utils/math.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const weightedMean = (values: number[], weights: number[]): number => {
|
|
2
2
|
const sum = values.reduce(
|
|
3
3
|
(acc: number, val: number, i: number) => acc + val * weights[i],
|
|
4
4
|
0,
|
|
@@ -8,11 +8,11 @@ export function weightedMean(values: number[], weights: number[]): number {
|
|
|
8
8
|
return sum / sumWeights
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export
|
|
11
|
+
export const amountFromPercentage = (
|
|
12
12
|
percentage: number,
|
|
13
13
|
amount: number,
|
|
14
14
|
roundingType: 'none' | 'round' | 'ceil' | 'floor' = 'none',
|
|
15
|
-
): number {
|
|
15
|
+
): number => {
|
|
16
16
|
if (Number.isNaN(Number(percentage)) || Number.isNaN(Number(amount))) {
|
|
17
17
|
throw new TypeError(`${percentage} || ${amount} is NaN`)
|
|
18
18
|
}
|
package/src/utils/numbers.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const generateNumbersFromStr = (str: string): [number, number] => {
|
|
2
2
|
let hash = 5381
|
|
3
3
|
for (let i = 0; i < str.length; i++) {
|
|
4
4
|
// eslint-disable-next-line no-bitwise
|
|
@@ -14,14 +14,13 @@ export function generateNumbersFromStr(str: string): [number, number] {
|
|
|
14
14
|
return [num1, num2]
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
}
|
|
17
|
+
export const randomInt = (min: number, max: number): number =>
|
|
18
|
+
Math.floor(Math.random() * (max - min + 1) + min)
|
|
20
19
|
|
|
21
|
-
export
|
|
20
|
+
export const computeSellingPrice = (
|
|
22
21
|
buyingPrice: number | string | null = 0,
|
|
23
22
|
rate: number | string | null = 0,
|
|
24
|
-
): number {
|
|
23
|
+
): number => {
|
|
25
24
|
if (Number.isNaN(Number(buyingPrice)) || Number.isNaN(Number(rate))) {
|
|
26
25
|
throw new TypeError('price or rate is NaN')
|
|
27
26
|
}
|
|
@@ -31,10 +30,10 @@ export function computeSellingPrice(
|
|
|
31
30
|
return Math.ceil(Math.floor(sellingPrice * 100) / 100)
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
export
|
|
33
|
+
export const computeMarginRate = (
|
|
35
34
|
buyingPrice: number | string,
|
|
36
35
|
sellingPrice: number | string,
|
|
37
|
-
): number {
|
|
36
|
+
): number => {
|
|
38
37
|
const buyingPriceNum = Number(buyingPrice)
|
|
39
38
|
const sellingPriceNum = Number(sellingPrice)
|
|
40
39
|
|
|
@@ -15,10 +15,10 @@ type Merge<T, S> = {
|
|
|
15
15
|
: never
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export
|
|
18
|
+
export const customMerge = <T extends object, S extends object>(
|
|
19
19
|
target: T,
|
|
20
20
|
source: S,
|
|
21
|
-
): Merge<T, S> {
|
|
21
|
+
): Merge<T, S> => {
|
|
22
22
|
for (const key of Object.keys(source)) {
|
|
23
23
|
const sourceValue = source[key as keyof S]
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -60,61 +60,3 @@ export function compactObject<T extends object>(obj: T): Partial<T> {
|
|
|
60
60
|
Object.entries(obj).filter(([, value]) => !isNil(value)),
|
|
61
61
|
) as Partial<T>
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Creates an object composed of keys generated from the results of running each element of collection through iteratee.
|
|
66
|
-
* The corresponding value of each key is the last element responsible for generating the key.
|
|
67
|
-
*
|
|
68
|
-
* @param collection - The collection to iterate over
|
|
69
|
-
* @param iteratee - The iteratee to transform keys. Can be a function or a property name
|
|
70
|
-
* @returns Returns the composed aggregate object
|
|
71
|
-
*/
|
|
72
|
-
export function keyBy<T>(
|
|
73
|
-
collection: T[],
|
|
74
|
-
iteratee: ((value: T) => string | number) | keyof T,
|
|
75
|
-
): Record<string, T> {
|
|
76
|
-
return collection.reduce<Record<string, T>>((acc, item) => {
|
|
77
|
-
const key =
|
|
78
|
-
typeof iteratee === 'function' ? iteratee(item) : String(item[iteratee])
|
|
79
|
-
acc[key] = item
|
|
80
|
-
return acc
|
|
81
|
-
}, {})
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Creates an object composed of the own enumerable properties of object that predicate doesn't return truthy for.
|
|
86
|
-
* The predicate is invoked with two arguments: (value, key).
|
|
87
|
-
* If predicate is a string, it omits the property with that key name.
|
|
88
|
-
*
|
|
89
|
-
* @param object - The source object
|
|
90
|
-
* @param predicate - The function invoked per property or a string key to omit
|
|
91
|
-
* @returns Returns the new object
|
|
92
|
-
*/
|
|
93
|
-
export function omitBy<T extends object>(
|
|
94
|
-
object: T,
|
|
95
|
-
predicate: ((value: T[keyof T], key: keyof T) => boolean) | string,
|
|
96
|
-
): Partial<T> {
|
|
97
|
-
const result = {} as Partial<T>
|
|
98
|
-
|
|
99
|
-
for (const key in object) {
|
|
100
|
-
if (Object.hasOwn(object, key)) {
|
|
101
|
-
const value = object[key]
|
|
102
|
-
|
|
103
|
-
// If predicate is a string, check if key matches
|
|
104
|
-
if (typeof predicate === 'string') {
|
|
105
|
-
// eslint-disable-next-line max-depth
|
|
106
|
-
if (key !== predicate) {
|
|
107
|
-
result[key] = value
|
|
108
|
-
}
|
|
109
|
-
} else if (typeof predicate === 'function') {
|
|
110
|
-
// If predicate is a function, use it
|
|
111
|
-
// eslint-disable-next-line max-depth
|
|
112
|
-
if (!predicate(value, key)) {
|
|
113
|
-
result[key] = value
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return result
|
|
120
|
-
}
|
package/src/utils/poller.ts
CHANGED
package/src/utils/strings.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
}
|
|
1
|
+
export const generatePseudoRandomString = (length: number): string =>
|
|
2
|
+
Array.from({ length }, () => Math.random().toString(36)[2]).join('')
|
|
4
3
|
|
|
5
|
-
/* @__PURE__ */
|
|
6
4
|
const TS_QUERY_SPECIAL_CHARS = new Set([
|
|
7
5
|
'&',
|
|
8
6
|
'|',
|
|
@@ -15,7 +13,6 @@ const TS_QUERY_SPECIAL_CHARS = new Set([
|
|
|
15
13
|
'@',
|
|
16
14
|
])
|
|
17
15
|
|
|
18
|
-
/* @__PURE__ */
|
|
19
16
|
const REGEX_SPECIAL_CHARS = new Set(['|', '(', ')'])
|
|
20
17
|
|
|
21
18
|
export function prepareTsQuery(query: string): string | null {
|
package/src/utils/validators.ts
CHANGED