@bash-app/bash-common 30.21.1 → 30.22.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/package.json +8 -3
- package/src/definitions.ts +20 -4
- package/src/index.ts +1 -0
- package/src/utils/objUtils.ts +41 -0
- package/.vscode/settings.json +0 -9
- package/scripts/symlinks.sh +0 -33
- package/tsconfig.json +0 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bash-app/bash-common",
|
|
3
|
-
"version": "30.
|
|
3
|
+
"version": "30.22.0",
|
|
4
4
|
"description": "Common data and scripts to use on the frontend and backend",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -46,6 +46,11 @@
|
|
|
46
46
|
"ts-jest": "^29.1.1",
|
|
47
47
|
"ts-node": "^10.9.1",
|
|
48
48
|
"tslib": "^2.6.2",
|
|
49
|
-
"typescript": "^5.
|
|
50
|
-
}
|
|
49
|
+
"typescript": "^5.3.3"
|
|
50
|
+
},
|
|
51
|
+
"files": [
|
|
52
|
+
"dist",
|
|
53
|
+
"src",
|
|
54
|
+
"prisma"
|
|
55
|
+
]
|
|
51
56
|
}
|
package/src/definitions.ts
CHANGED
|
@@ -11,11 +11,11 @@ import {
|
|
|
11
11
|
YearsOfExperience,
|
|
12
12
|
} from "@prisma/client";
|
|
13
13
|
import { CheckoutExt, PublicUser, ServiceBookingExt } from "./extendedSchemas";
|
|
14
|
-
import { ServiceSubscriptionTier } from "./utils/userSubscriptionUtils";
|
|
15
|
-
import { FrontendServiceGetPriceToBookResult } from "./utils/service/frontendServiceBookingUtils";
|
|
16
14
|
import { LuxonDateRange } from "./utils/luxonUtils";
|
|
17
15
|
import { ApiServiceCantBookReason } from "./utils/service/apiServiceBookingApiUtils";
|
|
18
16
|
import { ServiceAttendeeOption } from "./utils/service/attendeeOptionUtils";
|
|
17
|
+
import { FrontendServiceGetPriceToBookResult } from "./utils/service/frontendServiceBookingUtils";
|
|
18
|
+
import { ServiceSubscriptionTier } from "./utils/userSubscriptionUtils";
|
|
19
19
|
|
|
20
20
|
export const PASSWORD_MIN_LENGTH = 8 as const;
|
|
21
21
|
export const PASSWORD_REQUIREMENTS_REGEX = new RegExp(
|
|
@@ -256,7 +256,7 @@ export type ApiServiceBookingParams = {
|
|
|
256
256
|
bookedDays: ApiServiceBookedDayParams[];
|
|
257
257
|
timezone: string;
|
|
258
258
|
attendeeOption: ServiceAttendeeOption;
|
|
259
|
-
bashEventId?: string;
|
|
259
|
+
bashEventId?: string;
|
|
260
260
|
};
|
|
261
261
|
|
|
262
262
|
export type ApiServiceCanBookParams = {} & ApiServiceBookingParams;
|
|
@@ -391,6 +391,22 @@ export interface ApiResult<T, P extends ErrorDataType = ErrorDataType> {
|
|
|
391
391
|
rawResponse?: any;
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
+
export function removeDataFromResult<
|
|
395
|
+
T,
|
|
396
|
+
P extends ErrorDataType = ErrorDataType
|
|
397
|
+
>(
|
|
398
|
+
result: ApiResult<T, P> | null | undefined
|
|
399
|
+
): ApiResult<undefined, P> | undefined {
|
|
400
|
+
if (result == null) {
|
|
401
|
+
return undefined;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const { data, ...rest } = result;
|
|
405
|
+
return {
|
|
406
|
+
...rest,
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
|
|
394
410
|
export enum ApiErrorType {
|
|
395
411
|
Unknown = 1,
|
|
396
412
|
UserAlreadyHasMaximumAllowedFreeTicketsForBashEvent,
|
|
@@ -606,7 +622,7 @@ export const ASSET_MIME_TYPES_TO_EXT = {
|
|
|
606
622
|
"image/tiff": ".tiff",
|
|
607
623
|
"image/vnd": ".ico",
|
|
608
624
|
"video/mp4": ".mp4",
|
|
609
|
-
"application/pdf": ".pdf",
|
|
625
|
+
"application/pdf": ".pdf",
|
|
610
626
|
"video/mov": ".mov",
|
|
611
627
|
};
|
|
612
628
|
export const VALID_ASSET_MIME_TYPES = Object.keys(ASSET_MIME_TYPES_TO_EXT);
|
package/src/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * from "./utils/promoCodesUtils";
|
|
|
16
16
|
export * from "./utils/userPromoCodeUtils";
|
|
17
17
|
export * from "./utils/userSubscriptionUtils";
|
|
18
18
|
export * from "./utils/service/regexUtils";
|
|
19
|
+
export * from "./utils/objUtils"
|
|
19
20
|
export * from "./utils/service/serviceUtils";
|
|
20
21
|
export * from "./utils/service/venueUtils";
|
|
21
22
|
export * from "./utils/service/attendeeOptionUtils";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export function isObject(value: unknown): value is Record<string, unknown> {
|
|
2
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function deepMerge<
|
|
6
|
+
T extends Record<string, any>,
|
|
7
|
+
U extends Record<string, any>
|
|
8
|
+
>(
|
|
9
|
+
target: T | undefined | null,
|
|
10
|
+
source: U | undefined | null,
|
|
11
|
+
mergeArrays: boolean = false,
|
|
12
|
+
mergeCommon: boolean = false
|
|
13
|
+
): T & U {
|
|
14
|
+
const output = { ...(mergeCommon ? [] : target) } as T & U;
|
|
15
|
+
|
|
16
|
+
for (const key in source) {
|
|
17
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
18
|
+
const sourceVal = source[key];
|
|
19
|
+
const targetVal = target ? target[key] : undefined;
|
|
20
|
+
|
|
21
|
+
if (mergeArrays && Array.isArray(sourceVal) && Array.isArray(targetVal)) {
|
|
22
|
+
// Merge arrays by concatenating them.
|
|
23
|
+
output[key] = [...targetVal, ...sourceVal] as (T & U)[Extract<
|
|
24
|
+
keyof U,
|
|
25
|
+
string
|
|
26
|
+
>];
|
|
27
|
+
} else if (isObject(sourceVal) && isObject(targetVal)) {
|
|
28
|
+
// When both values are objects, merge them recursively.
|
|
29
|
+
output[key] = deepMerge(targetVal, sourceVal) as (T & U)[Extract<
|
|
30
|
+
keyof U,
|
|
31
|
+
string
|
|
32
|
+
>];
|
|
33
|
+
} else {
|
|
34
|
+
// Otherwise, overwrite target with source.
|
|
35
|
+
output[key] = sourceVal as (T & U)[Extract<keyof U, string>];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return output;
|
|
41
|
+
}
|
package/.vscode/settings.json
DELETED
package/scripts/symlinks.sh
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#! /bin/bash
|
|
2
|
-
|
|
3
|
-
# run this script after any schema change to make sure the typescript defintions are updated or
|
|
4
|
-
#... or if npm i is run on any of the repos, as it may overwrite the symlink
|
|
5
|
-
|
|
6
|
-
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|
7
|
-
|
|
8
|
-
PATH_TO_PARENT_DIR="../.."
|
|
9
|
-
NODE_MODULES_PATH="node_modules/@bash-app"
|
|
10
|
-
FRONT_END_TARGET="$SCRIPT_DIR/$PATH_TO_PARENT_DIR/bash-app"
|
|
11
|
-
API_TARGET="$SCRIPT_DIR/$PATH_TO_PARENT_DIR/api"
|
|
12
|
-
|
|
13
|
-
TARGETS=(
|
|
14
|
-
$FRONT_END_TARGET
|
|
15
|
-
$API_TARGET
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
BASH_COMMON_TARGET="$SCRIPT_DIR/$PATH_TO_PARENT_DIR/bash-common"
|
|
19
|
-
|
|
20
|
-
echo "FRONT_END_TARGET: $FRONT_END_TARGET"
|
|
21
|
-
echo "API_TARGET: $API_TARGET"
|
|
22
|
-
echo "BASH_COMMON_TARGET: $BASH_COMMON_TARGET"
|
|
23
|
-
printf "\n\n"
|
|
24
|
-
|
|
25
|
-
cd $BASH_COMMON_TARGET && npx prisma generate
|
|
26
|
-
|
|
27
|
-
for TARGET in "${TARGETS[@]}"; do
|
|
28
|
-
rm -rf "$TARGET/$NODE_MODULES_PATH"
|
|
29
|
-
mkdir -p "$TARGET/$NODE_MODULES_PATH"
|
|
30
|
-
|
|
31
|
-
ln -s "$BASH_COMMON_TARGET" "$TARGET/$NODE_MODULES_PATH"
|
|
32
|
-
cd $TARGET && cp -rf "./$NODE_MODULES_PATH/bash-common/prisma" . && npm run generate
|
|
33
|
-
done
|
package/tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2022",
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"noEmit": true,
|
|
8
|
-
"outDir": "./dist",
|
|
9
|
-
"rootDir": "./src",
|
|
10
|
-
"strict": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
"jsx": "react-jsx",
|
|
14
|
-
"noImplicitAny": true,
|
|
15
|
-
"sourceMap": true
|
|
16
|
-
},
|
|
17
|
-
"include": ["src/**/*.ts", "src/**/*.tsx", "src/types/**/*.d.ts"],
|
|
18
|
-
"exclude": ["node_modules"]
|
|
19
|
-
}
|