@goweekdays/core 2.10.1 → 2.10.2
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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +94 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -398,6 +398,7 @@ declare function useOrgRepo(): {
|
|
|
398
398
|
getByEmail: (email: string) => Promise<TOrg | null>;
|
|
399
399
|
updateById: (_id: string | ObjectId, options: Pick<TOrg, "name" | "description" | "email" | "contact">) => Promise<void>;
|
|
400
400
|
updateStatusById: (_id: string | ObjectId, status: string, session?: ClientSession) => Promise<string>;
|
|
401
|
+
companySearch: (name: string) => Promise<bson.Document[]>;
|
|
401
402
|
};
|
|
402
403
|
|
|
403
404
|
declare function useOrgService(): {
|
|
@@ -417,6 +418,7 @@ declare function useOrgController(): {
|
|
|
417
418
|
getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
418
419
|
getById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
419
420
|
updateById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
421
|
+
companySearch: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
420
422
|
};
|
|
421
423
|
|
|
422
424
|
type TPromo = {
|
|
@@ -765,9 +767,7 @@ declare function useVerificationService(): {
|
|
|
765
767
|
}) => Promise<bson.ObjectId>;
|
|
766
768
|
cancelInviteMember: (id: string) => Promise<string>;
|
|
767
769
|
forgetPassword: (email: string) => Promise<string>;
|
|
768
|
-
orgSetupFee: (value: TOrg
|
|
769
|
-
seats: number;
|
|
770
|
-
}) => Promise<{
|
|
770
|
+
orgSetupFee: (value: TOrg) => Promise<{
|
|
771
771
|
paypalOrderLink: any;
|
|
772
772
|
}>;
|
|
773
773
|
};
|
|
@@ -1077,6 +1077,8 @@ type TJobPost = {
|
|
|
1077
1077
|
_id?: ObjectId;
|
|
1078
1078
|
org: ObjectId | string;
|
|
1079
1079
|
orgName?: string;
|
|
1080
|
+
company: ObjectId;
|
|
1081
|
+
companyName?: string;
|
|
1080
1082
|
title: string;
|
|
1081
1083
|
setup: string;
|
|
1082
1084
|
location: string;
|
package/dist/index.js
CHANGED
|
@@ -4446,8 +4446,7 @@ var schemaOrg = import_joi15.default.object({
|
|
|
4446
4446
|
});
|
|
4447
4447
|
var schemaOrgAdd = import_joi15.default.object({
|
|
4448
4448
|
...schema,
|
|
4449
|
-
createdBy: import_joi15.default.string().hex().required()
|
|
4450
|
-
seats: import_joi15.default.number().required()
|
|
4449
|
+
createdBy: import_joi15.default.string().hex().required()
|
|
4451
4450
|
});
|
|
4452
4451
|
var schemaOrgUpdate = import_joi15.default.object({
|
|
4453
4452
|
...schema,
|
|
@@ -4808,6 +4807,50 @@ function useOrgRepo() {
|
|
|
4808
4807
|
throw new import_utils22.InternalServerError("Failed to update organization status.");
|
|
4809
4808
|
}
|
|
4810
4809
|
}
|
|
4810
|
+
async function companySearch(name) {
|
|
4811
|
+
const { error } = import_joi16.default.string().trim().min(2).required().validate(name);
|
|
4812
|
+
if (error) {
|
|
4813
|
+
throw new import_utils22.BadRequestError(error.message);
|
|
4814
|
+
}
|
|
4815
|
+
try {
|
|
4816
|
+
const cacheKey = (0, import_utils22.makeCacheKey)(namespace_collection, {
|
|
4817
|
+
name,
|
|
4818
|
+
tag: "companySearch"
|
|
4819
|
+
});
|
|
4820
|
+
const cached = await getCache(
|
|
4821
|
+
cacheKey
|
|
4822
|
+
);
|
|
4823
|
+
if (cached) {
|
|
4824
|
+
import_utils22.logger.log({
|
|
4825
|
+
level: "info",
|
|
4826
|
+
message: `Cache hit for companySearch: ${cacheKey}`
|
|
4827
|
+
});
|
|
4828
|
+
return cached;
|
|
4829
|
+
}
|
|
4830
|
+
const results = await collection.aggregate([
|
|
4831
|
+
{ $match: { $text: { $search: name }, status: "active" } },
|
|
4832
|
+
{ $limit: 100 },
|
|
4833
|
+
{ $project: { value: "$_id", title: "$name" } }
|
|
4834
|
+
]).toArray();
|
|
4835
|
+
setCache(cacheKey, results, 300).then(() => {
|
|
4836
|
+
import_utils22.logger.log({
|
|
4837
|
+
level: "info",
|
|
4838
|
+
message: `Cache set for companySearch: ${cacheKey}`
|
|
4839
|
+
});
|
|
4840
|
+
}).catch((err) => {
|
|
4841
|
+
import_utils22.logger.log({
|
|
4842
|
+
level: "error",
|
|
4843
|
+
message: `Failed to set cache for companySearch: ${err.message}`
|
|
4844
|
+
});
|
|
4845
|
+
});
|
|
4846
|
+
return results;
|
|
4847
|
+
} catch (error2) {
|
|
4848
|
+
if (error2 instanceof import_utils22.AppError) {
|
|
4849
|
+
throw error2;
|
|
4850
|
+
}
|
|
4851
|
+
throw new import_utils22.InternalServerError("Failed to search companies.");
|
|
4852
|
+
}
|
|
4853
|
+
}
|
|
4811
4854
|
return {
|
|
4812
4855
|
createIndexes,
|
|
4813
4856
|
add,
|
|
@@ -4818,7 +4861,8 @@ function useOrgRepo() {
|
|
|
4818
4861
|
getByName,
|
|
4819
4862
|
getByEmail,
|
|
4820
4863
|
updateById,
|
|
4821
|
-
updateStatusById
|
|
4864
|
+
updateStatusById,
|
|
4865
|
+
companySearch
|
|
4822
4866
|
};
|
|
4823
4867
|
}
|
|
4824
4868
|
|
|
@@ -7807,6 +7851,12 @@ function useSubscriptionController() {
|
|
|
7807
7851
|
}
|
|
7808
7852
|
try {
|
|
7809
7853
|
const data = await _getByOrg(value.org);
|
|
7854
|
+
if (!data) {
|
|
7855
|
+
next(
|
|
7856
|
+
new import_utils41.BadRequestError("Subscription not found for this organization")
|
|
7857
|
+
);
|
|
7858
|
+
return;
|
|
7859
|
+
}
|
|
7810
7860
|
res.json(data);
|
|
7811
7861
|
return;
|
|
7812
7862
|
} catch (error2) {
|
|
@@ -8279,9 +8329,6 @@ function useOrgService() {
|
|
|
8279
8329
|
if (!verification.metadata?.orgName) {
|
|
8280
8330
|
throw new import_utils44.BadRequestError("Organization name is required.");
|
|
8281
8331
|
}
|
|
8282
|
-
if (!verification.metadata?.seats) {
|
|
8283
|
-
throw new import_utils44.BadRequestError("Number of seats is required.");
|
|
8284
|
-
}
|
|
8285
8332
|
if (!verification.metadata?.createdBy) {
|
|
8286
8333
|
throw new import_utils44.BadRequestError("CreatedBy is required.");
|
|
8287
8334
|
}
|
|
@@ -8306,19 +8353,6 @@ function useOrgService() {
|
|
|
8306
8353
|
const currentDate = /* @__PURE__ */ new Date();
|
|
8307
8354
|
const nextBillingDate = new Date(currentDate);
|
|
8308
8355
|
nextBillingDate.setMonth(currentDate.getMonth() + 1);
|
|
8309
|
-
const amount = plan.price * verification.metadata.seats;
|
|
8310
|
-
await addSubscription(
|
|
8311
|
-
{
|
|
8312
|
-
amount,
|
|
8313
|
-
org: String(org),
|
|
8314
|
-
seats: verification.metadata.seats,
|
|
8315
|
-
paidSeats: verification.metadata.seats,
|
|
8316
|
-
currency: plan.currency,
|
|
8317
|
-
billingCycle: plan.billingCycle,
|
|
8318
|
-
nextBillingDate
|
|
8319
|
-
},
|
|
8320
|
-
session
|
|
8321
|
-
);
|
|
8322
8356
|
const createdBy = String(verification.metadata.createdBy);
|
|
8323
8357
|
const user = await getUserById(createdBy);
|
|
8324
8358
|
if (!user) {
|
|
@@ -8418,7 +8452,8 @@ function useOrgController() {
|
|
|
8418
8452
|
getByName: _getByName,
|
|
8419
8453
|
getAll: getAllOrg,
|
|
8420
8454
|
getById: _getById,
|
|
8421
|
-
updateById: _updateById
|
|
8455
|
+
updateById: _updateById,
|
|
8456
|
+
companySearch: _companySearch
|
|
8422
8457
|
} = useOrgRepo();
|
|
8423
8458
|
async function add(req, res, next) {
|
|
8424
8459
|
const value = req.body;
|
|
@@ -8559,13 +8594,29 @@ function useOrgController() {
|
|
|
8559
8594
|
next(error2);
|
|
8560
8595
|
}
|
|
8561
8596
|
}
|
|
8597
|
+
async function companySearch(req, res, next) {
|
|
8598
|
+
const search = req.query.search ?? "";
|
|
8599
|
+
const { error } = import_joi37.default.string().min(1).required().validate(search);
|
|
8600
|
+
if (error) {
|
|
8601
|
+
next(new import_utils45.BadRequestError(`${error.message} - controller`));
|
|
8602
|
+
return;
|
|
8603
|
+
}
|
|
8604
|
+
try {
|
|
8605
|
+
const companies = await _companySearch(search);
|
|
8606
|
+
res.json(companies);
|
|
8607
|
+
return;
|
|
8608
|
+
} catch (error2) {
|
|
8609
|
+
next(error2);
|
|
8610
|
+
}
|
|
8611
|
+
}
|
|
8562
8612
|
return {
|
|
8563
8613
|
add,
|
|
8564
8614
|
getOrgsByUserId,
|
|
8565
8615
|
getByName,
|
|
8566
8616
|
getAll,
|
|
8567
8617
|
getById,
|
|
8568
|
-
updateById
|
|
8618
|
+
updateById,
|
|
8619
|
+
companySearch
|
|
8569
8620
|
};
|
|
8570
8621
|
}
|
|
8571
8622
|
|
|
@@ -9492,6 +9543,7 @@ function useVerificationService() {
|
|
|
9492
9543
|
throw error;
|
|
9493
9544
|
}
|
|
9494
9545
|
}
|
|
9546
|
+
const { getByOrg } = useSubscriptionRepo();
|
|
9495
9547
|
async function inviteMember(value) {
|
|
9496
9548
|
const { error } = schemaInviteMember.validate(value);
|
|
9497
9549
|
if (error) {
|
|
@@ -9507,6 +9559,12 @@ function useVerificationService() {
|
|
|
9507
9559
|
if (!org) {
|
|
9508
9560
|
throw new import_utils48.NotFoundError("Organization not found.");
|
|
9509
9561
|
}
|
|
9562
|
+
const subscription = await getByOrg(String(value.org));
|
|
9563
|
+
if (!subscription) {
|
|
9564
|
+
throw new import_utils48.BadRequestError(
|
|
9565
|
+
"Organization does not have an active subscription."
|
|
9566
|
+
);
|
|
9567
|
+
}
|
|
9510
9568
|
}
|
|
9511
9569
|
let verificationData = {
|
|
9512
9570
|
type: "user-invite",
|
|
@@ -9673,7 +9731,6 @@ function useVerificationService() {
|
|
|
9673
9731
|
type: "org-setup-fee",
|
|
9674
9732
|
email: value.email,
|
|
9675
9733
|
metadata: {
|
|
9676
|
-
seats: value.seats,
|
|
9677
9734
|
contact: value.contact,
|
|
9678
9735
|
orgName: value.name,
|
|
9679
9736
|
createdBy: value.createdBy,
|
|
@@ -11902,6 +11959,10 @@ function usePromoController() {
|
|
|
11902
11959
|
}
|
|
11903
11960
|
try {
|
|
11904
11961
|
const promo = await _getByCode(code);
|
|
11962
|
+
if (!promo) {
|
|
11963
|
+
next(new import_utils65.BadRequestError("Invalid promo code, promo code not found."));
|
|
11964
|
+
return;
|
|
11965
|
+
}
|
|
11905
11966
|
res.json(promo);
|
|
11906
11967
|
return;
|
|
11907
11968
|
} catch (error2) {
|
|
@@ -11981,6 +12042,8 @@ var schemaJobPost = import_joi50.default.object({
|
|
|
11981
12042
|
_id: import_joi50.default.string().hex().optional(),
|
|
11982
12043
|
org: import_joi50.default.string().hex().required(),
|
|
11983
12044
|
orgName: import_joi50.default.string().optional().allow("", null),
|
|
12045
|
+
company: import_joi50.default.string().hex().required(),
|
|
12046
|
+
companyName: import_joi50.default.string().optional().allow("", null),
|
|
11984
12047
|
title: import_joi50.default.string().trim().required(),
|
|
11985
12048
|
setup: import_joi50.default.string().trim().required(),
|
|
11986
12049
|
location: import_joi50.default.string().trim().required(),
|
|
@@ -11997,6 +12060,8 @@ var schemaJobPost = import_joi50.default.object({
|
|
|
11997
12060
|
});
|
|
11998
12061
|
var schemaJobPostUpdate = import_joi50.default.object({
|
|
11999
12062
|
_id: import_joi50.default.string().hex().required(),
|
|
12063
|
+
company: import_joi50.default.string().hex().required(),
|
|
12064
|
+
companyName: import_joi50.default.string().optional().allow("", null),
|
|
12000
12065
|
title: import_joi50.default.string().trim().required(),
|
|
12001
12066
|
setup: import_joi50.default.string().trim().required(),
|
|
12002
12067
|
location: import_joi50.default.string().trim().required(),
|
|
@@ -12024,10 +12089,17 @@ function modelJobPost(value) {
|
|
|
12024
12089
|
} catch (error2) {
|
|
12025
12090
|
throw new import_utils66.BadRequestError("Invalid Org ID");
|
|
12026
12091
|
}
|
|
12092
|
+
try {
|
|
12093
|
+
value.company = new import_mongodb29.ObjectId(value.company);
|
|
12094
|
+
} catch (error2) {
|
|
12095
|
+
throw new import_utils66.BadRequestError("Invalid Company ID");
|
|
12096
|
+
}
|
|
12027
12097
|
return {
|
|
12028
12098
|
_id: value._id,
|
|
12029
12099
|
org: value.org,
|
|
12030
12100
|
orgName: value.orgName ?? "",
|
|
12101
|
+
company: value.company,
|
|
12102
|
+
companyName: value.companyName ?? "",
|
|
12031
12103
|
title: value.title,
|
|
12032
12104
|
setup: value.setup,
|
|
12033
12105
|
location: value.location,
|