@goweekdays/core 0.0.8 → 0.0.9
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 +7 -2
- package/dist/index.js +119 -104
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +119 -104
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -989,14 +989,19 @@ declare function usePaymentMethodRepo(): {
|
|
|
989
989
|
};
|
|
990
990
|
|
|
991
991
|
declare function usePaymentMethodService(): {
|
|
992
|
-
linkEWallet: ({ user, mobile_number, type, success_return_url, failure_return_url, cancel_return_url, }?: {
|
|
992
|
+
linkEWallet: ({ user, mobile_number, type, success_return_url, failure_return_url, cancel_return_url, metadata, }?: {
|
|
993
993
|
user?: string | undefined;
|
|
994
994
|
mobile_number?: string | undefined;
|
|
995
995
|
type?: string | undefined;
|
|
996
996
|
success_return_url?: string | undefined;
|
|
997
997
|
failure_return_url?: string | undefined;
|
|
998
998
|
cancel_return_url?: string | undefined;
|
|
999
|
-
|
|
999
|
+
metadata?: {} | undefined;
|
|
1000
|
+
}) => Promise<{
|
|
1001
|
+
paymentMethod: any;
|
|
1002
|
+
customer: any;
|
|
1003
|
+
actions: any;
|
|
1004
|
+
}>;
|
|
1000
1005
|
linkCard: ({ user, type, success_return_url, failure_return_url, card_number, expiry_month, expiry_year, cvv, cardholder_name, currency, }?: {
|
|
1001
1006
|
user?: string | undefined;
|
|
1002
1007
|
type?: string | undefined;
|
package/dist/index.js
CHANGED
|
@@ -19535,8 +19535,43 @@ function useSubscriptionService() {
|
|
|
19535
19535
|
}
|
|
19536
19536
|
|
|
19537
19537
|
// src/controllers/subscription.controller.ts
|
|
19538
|
-
var
|
|
19538
|
+
var import_joi12 = __toESM(require("joi"));
|
|
19539
19539
|
var import_utils62 = require("@goweekdays/utils");
|
|
19540
|
+
|
|
19541
|
+
// src/validations/subscription.schema.ts
|
|
19542
|
+
var import_joi11 = __toESM(require("joi"));
|
|
19543
|
+
function useSubscriptionSchema() {
|
|
19544
|
+
const schema = import_joi11.default.object({
|
|
19545
|
+
user: import_joi11.default.string().required(),
|
|
19546
|
+
amount: import_joi11.default.number().required(),
|
|
19547
|
+
customer_id: import_joi11.default.string().required(),
|
|
19548
|
+
payment_method_id: import_joi11.default.string().required(),
|
|
19549
|
+
currency: import_joi11.default.string().optional().allow("", null),
|
|
19550
|
+
organization: import_joi11.default.object({
|
|
19551
|
+
name: import_joi11.default.string().required(),
|
|
19552
|
+
description: import_joi11.default.string().optional().allow("", null),
|
|
19553
|
+
type: import_joi11.default.string().allow("personal", "business").required(),
|
|
19554
|
+
email: import_joi11.default.string().email().required(),
|
|
19555
|
+
contact: import_joi11.default.string().required(),
|
|
19556
|
+
busInst: import_joi11.default.string().optional().allow(null, "")
|
|
19557
|
+
}).required(),
|
|
19558
|
+
billingAddress: import_joi11.default.object({
|
|
19559
|
+
type: import_joi11.default.string().required(),
|
|
19560
|
+
country: import_joi11.default.string().required(),
|
|
19561
|
+
address: import_joi11.default.string().required(),
|
|
19562
|
+
continuedAddress: import_joi11.default.string().optional().allow(null, ""),
|
|
19563
|
+
city: import_joi11.default.string().required(),
|
|
19564
|
+
province: import_joi11.default.string().required(),
|
|
19565
|
+
postalCode: import_joi11.default.string().required(),
|
|
19566
|
+
taxId: import_joi11.default.string().optional().allow(null, "")
|
|
19567
|
+
}).required()
|
|
19568
|
+
});
|
|
19569
|
+
return {
|
|
19570
|
+
schema
|
|
19571
|
+
};
|
|
19572
|
+
}
|
|
19573
|
+
|
|
19574
|
+
// src/controllers/subscription.controller.ts
|
|
19540
19575
|
function useSubscriptionController() {
|
|
19541
19576
|
const { add: _add, getSubscriptions: _getSubscriptions } = useSubscriptionRepo();
|
|
19542
19577
|
const {
|
|
@@ -19547,9 +19582,9 @@ function useSubscriptionController() {
|
|
|
19547
19582
|
} = useSubscriptionService();
|
|
19548
19583
|
async function add(req, res, next) {
|
|
19549
19584
|
const value = req.body;
|
|
19550
|
-
const validation =
|
|
19551
|
-
user:
|
|
19552
|
-
subscriptionId:
|
|
19585
|
+
const validation = import_joi12.default.object({
|
|
19586
|
+
user: import_joi12.default.string().required(),
|
|
19587
|
+
subscriptionId: import_joi12.default.string().required()
|
|
19553
19588
|
});
|
|
19554
19589
|
const { error } = validation.validate(value);
|
|
19555
19590
|
if (error) {
|
|
@@ -19566,7 +19601,7 @@ function useSubscriptionController() {
|
|
|
19566
19601
|
}
|
|
19567
19602
|
async function getByUserId(req, res, next) {
|
|
19568
19603
|
const id = req.params.id;
|
|
19569
|
-
const validation =
|
|
19604
|
+
const validation = import_joi12.default.string().required();
|
|
19570
19605
|
const { error } = validation.validate(id);
|
|
19571
19606
|
if (error) {
|
|
19572
19607
|
next(new import_utils62.BadRequestError(error.message));
|
|
@@ -19583,10 +19618,10 @@ function useSubscriptionController() {
|
|
|
19583
19618
|
const status = req.query.status ?? "";
|
|
19584
19619
|
const search = req.query.search ?? "";
|
|
19585
19620
|
const page = Number(req.query.page) ?? 1;
|
|
19586
|
-
const validation =
|
|
19587
|
-
status:
|
|
19588
|
-
search:
|
|
19589
|
-
page:
|
|
19621
|
+
const validation = import_joi12.default.object({
|
|
19622
|
+
status: import_joi12.default.string().required(),
|
|
19623
|
+
search: import_joi12.default.string().optional().allow("", null),
|
|
19624
|
+
page: import_joi12.default.number().required()
|
|
19590
19625
|
});
|
|
19591
19626
|
const { error } = validation.validate({ status, search, page });
|
|
19592
19627
|
if (error) {
|
|
@@ -19602,7 +19637,7 @@ function useSubscriptionController() {
|
|
|
19602
19637
|
}
|
|
19603
19638
|
async function getSubscriptionStatus(req, res, next) {
|
|
19604
19639
|
const id = req.params.id;
|
|
19605
|
-
const validation =
|
|
19640
|
+
const validation = import_joi12.default.string().required();
|
|
19606
19641
|
const { error } = validation.validate(id);
|
|
19607
19642
|
if (error) {
|
|
19608
19643
|
next(new import_utils62.BadRequestError(error.message));
|
|
@@ -19621,12 +19656,12 @@ function useSubscriptionController() {
|
|
|
19621
19656
|
const customer_id = req.body.customer_id ?? "";
|
|
19622
19657
|
const currency = req.body.currency ?? "PHP";
|
|
19623
19658
|
const user = req.headers["user"];
|
|
19624
|
-
const validation =
|
|
19625
|
-
user:
|
|
19626
|
-
amount:
|
|
19627
|
-
customer_id:
|
|
19628
|
-
payment_method_id:
|
|
19629
|
-
currency:
|
|
19659
|
+
const validation = import_joi12.default.object({
|
|
19660
|
+
user: import_joi12.default.string().required(),
|
|
19661
|
+
amount: import_joi12.default.number().required(),
|
|
19662
|
+
customer_id: import_joi12.default.string().required(),
|
|
19663
|
+
payment_method_id: import_joi12.default.string().required(),
|
|
19664
|
+
currency: import_joi12.default.string().optional().allow("", null)
|
|
19630
19665
|
});
|
|
19631
19666
|
const { error } = validation.validate({
|
|
19632
19667
|
user,
|
|
@@ -19654,35 +19689,11 @@ function useSubscriptionController() {
|
|
|
19654
19689
|
return;
|
|
19655
19690
|
}
|
|
19656
19691
|
}
|
|
19692
|
+
const { schema: subscriptionSchema } = useSubscriptionSchema();
|
|
19657
19693
|
async function createOrgSubscription(req, res, next) {
|
|
19658
19694
|
const value = req.body;
|
|
19659
19695
|
value.user = req.headers["user"];
|
|
19660
|
-
const
|
|
19661
|
-
user: import_joi11.default.string().required(),
|
|
19662
|
-
amount: import_joi11.default.number().required(),
|
|
19663
|
-
customer_id: import_joi11.default.string().required(),
|
|
19664
|
-
payment_method_id: import_joi11.default.string().required(),
|
|
19665
|
-
currency: import_joi11.default.string().optional().allow("", null),
|
|
19666
|
-
organization: import_joi11.default.object({
|
|
19667
|
-
name: import_joi11.default.string().required(),
|
|
19668
|
-
description: import_joi11.default.string().optional().allow("", null),
|
|
19669
|
-
type: import_joi11.default.string().allow("personal", "business").required(),
|
|
19670
|
-
email: import_joi11.default.string().email().required(),
|
|
19671
|
-
contact: import_joi11.default.string().required(),
|
|
19672
|
-
busInst: import_joi11.default.string().optional().allow(null, "")
|
|
19673
|
-
}).required(),
|
|
19674
|
-
billingAddress: import_joi11.default.object({
|
|
19675
|
-
type: import_joi11.default.string().required(),
|
|
19676
|
-
country: import_joi11.default.string().required(),
|
|
19677
|
-
address: import_joi11.default.string().required(),
|
|
19678
|
-
continuedAddress: import_joi11.default.string().optional().allow(null, ""),
|
|
19679
|
-
city: import_joi11.default.string().required(),
|
|
19680
|
-
province: import_joi11.default.string().required(),
|
|
19681
|
-
postalCode: import_joi11.default.string().required(),
|
|
19682
|
-
taxId: import_joi11.default.string().optional().allow(null, "")
|
|
19683
|
-
}).required()
|
|
19684
|
-
});
|
|
19685
|
-
const { error } = validation.validate(value);
|
|
19696
|
+
const { error } = subscriptionSchema.validate(value);
|
|
19686
19697
|
if (error) {
|
|
19687
19698
|
next(new import_utils62.BadRequestError(error.message));
|
|
19688
19699
|
return;
|
|
@@ -19756,7 +19767,8 @@ function usePaymentMethodService() {
|
|
|
19756
19767
|
type = "GCASH",
|
|
19757
19768
|
success_return_url = "",
|
|
19758
19769
|
failure_return_url = "",
|
|
19759
|
-
cancel_return_url = ""
|
|
19770
|
+
cancel_return_url = "",
|
|
19771
|
+
metadata = {}
|
|
19760
19772
|
} = {}) {
|
|
19761
19773
|
const session = import_utils63.useAtlas.getClient()?.startSession();
|
|
19762
19774
|
session?.startTransaction();
|
|
@@ -19774,7 +19786,7 @@ function usePaymentMethodService() {
|
|
|
19774
19786
|
given_names: _user.firstName,
|
|
19775
19787
|
surname: _user.lastName
|
|
19776
19788
|
});
|
|
19777
|
-
const
|
|
19789
|
+
const paymentMethod = await linkPaymentMethodEWallet({
|
|
19778
19790
|
customerId: customer.id,
|
|
19779
19791
|
type,
|
|
19780
19792
|
success_return_url,
|
|
@@ -19786,17 +19798,20 @@ function usePaymentMethodService() {
|
|
|
19786
19798
|
user: _user._id,
|
|
19787
19799
|
type,
|
|
19788
19800
|
status: "active",
|
|
19789
|
-
paymentId:
|
|
19801
|
+
paymentId: paymentMethod.id,
|
|
19790
19802
|
customerId: customer.id,
|
|
19791
|
-
name:
|
|
19803
|
+
name: paymentMethod.type,
|
|
19792
19804
|
number: mobile_number
|
|
19793
19805
|
},
|
|
19794
19806
|
session
|
|
19795
19807
|
);
|
|
19796
19808
|
await session?.commitTransaction();
|
|
19797
|
-
return
|
|
19809
|
+
return {
|
|
19810
|
+
paymentMethod: paymentMethod.id,
|
|
19811
|
+
customer: customer.id,
|
|
19812
|
+
actions: paymentMethod.actions
|
|
19813
|
+
};
|
|
19798
19814
|
} catch (error) {
|
|
19799
|
-
console.log(error);
|
|
19800
19815
|
await session?.abortTransaction();
|
|
19801
19816
|
throw error;
|
|
19802
19817
|
} finally {
|
|
@@ -19863,7 +19878,7 @@ function usePaymentMethodService() {
|
|
|
19863
19878
|
}
|
|
19864
19879
|
|
|
19865
19880
|
// src/controllers/payment-method.controller.ts
|
|
19866
|
-
var
|
|
19881
|
+
var import_joi13 = __toESM(require("joi"));
|
|
19867
19882
|
var import_utils64 = require("@goweekdays/utils");
|
|
19868
19883
|
function usePaymentMethodController() {
|
|
19869
19884
|
const { linkEWallet: _linkEWallet, linkCard: _linkCard } = usePaymentMethodService();
|
|
@@ -19874,13 +19889,13 @@ function usePaymentMethodController() {
|
|
|
19874
19889
|
const success_return_url = req.body.success_return_url ?? "";
|
|
19875
19890
|
const failure_return_url = req.body.failure_return_url ?? "";
|
|
19876
19891
|
const cancel_return_url = req.body.cancel_return_url ?? "";
|
|
19877
|
-
const validation =
|
|
19878
|
-
user:
|
|
19879
|
-
mobile_number:
|
|
19880
|
-
type:
|
|
19881
|
-
success_return_url:
|
|
19882
|
-
failure_return_url:
|
|
19883
|
-
cancel_return_url:
|
|
19892
|
+
const validation = import_joi13.default.object({
|
|
19893
|
+
user: import_joi13.default.string().hex().required(),
|
|
19894
|
+
mobile_number: import_joi13.default.string().required(),
|
|
19895
|
+
type: import_joi13.default.string().valid("GCASH", "PAYMAYA").required(),
|
|
19896
|
+
success_return_url: import_joi13.default.string().uri().required(),
|
|
19897
|
+
failure_return_url: import_joi13.default.string().uri().required(),
|
|
19898
|
+
cancel_return_url: import_joi13.default.string().uri().required()
|
|
19884
19899
|
});
|
|
19885
19900
|
const { error } = validation.validate({
|
|
19886
19901
|
user,
|
|
@@ -19919,17 +19934,17 @@ function usePaymentMethodController() {
|
|
|
19919
19934
|
const failure_return_url = req.body.failure_return_url ?? "";
|
|
19920
19935
|
const cardType = req.body.cardType ?? "";
|
|
19921
19936
|
const user = req.headers["user"] ?? "";
|
|
19922
|
-
const validation =
|
|
19923
|
-
cardNumber:
|
|
19924
|
-
expiryMonth:
|
|
19925
|
-
expiryYear:
|
|
19926
|
-
cvv:
|
|
19927
|
-
cardholderName:
|
|
19928
|
-
currency:
|
|
19929
|
-
success_return_url:
|
|
19930
|
-
failure_return_url:
|
|
19931
|
-
cardType:
|
|
19932
|
-
user:
|
|
19937
|
+
const validation = import_joi13.default.object({
|
|
19938
|
+
cardNumber: import_joi13.default.string().required(),
|
|
19939
|
+
expiryMonth: import_joi13.default.string().required(),
|
|
19940
|
+
expiryYear: import_joi13.default.string().required(),
|
|
19941
|
+
cvv: import_joi13.default.string().required(),
|
|
19942
|
+
cardholderName: import_joi13.default.string().required(),
|
|
19943
|
+
currency: import_joi13.default.string().optional().allow("", null),
|
|
19944
|
+
success_return_url: import_joi13.default.string().uri().required(),
|
|
19945
|
+
failure_return_url: import_joi13.default.string().uri().required(),
|
|
19946
|
+
cardType: import_joi13.default.string().required(),
|
|
19947
|
+
user: import_joi13.default.string().hex().required()
|
|
19933
19948
|
});
|
|
19934
19949
|
const { error } = validation.validate({
|
|
19935
19950
|
user,
|
|
@@ -19984,22 +19999,22 @@ function usePaymentMethodController() {
|
|
|
19984
19999
|
|
|
19985
20000
|
// src/controllers/address.controller.ts
|
|
19986
20001
|
var import_utils65 = require("@goweekdays/utils");
|
|
19987
|
-
var
|
|
20002
|
+
var import_joi14 = __toESM(require("joi"));
|
|
19988
20003
|
function useAddressController() {
|
|
19989
20004
|
const { add: _add, getByUserId: _getByUserId } = useAddressRepo();
|
|
19990
20005
|
async function add(req, res, next) {
|
|
19991
20006
|
const value = req.body;
|
|
19992
|
-
const validation =
|
|
19993
|
-
type:
|
|
19994
|
-
user:
|
|
19995
|
-
org:
|
|
19996
|
-
country:
|
|
19997
|
-
address:
|
|
19998
|
-
continuedAddress:
|
|
19999
|
-
city:
|
|
20000
|
-
province:
|
|
20001
|
-
postalCode:
|
|
20002
|
-
taxId:
|
|
20007
|
+
const validation = import_joi14.default.object({
|
|
20008
|
+
type: import_joi14.default.string().required(),
|
|
20009
|
+
user: import_joi14.default.string().hex().optional().allow("", null),
|
|
20010
|
+
org: import_joi14.default.string().hex().optional().allow("", null),
|
|
20011
|
+
country: import_joi14.default.string().required(),
|
|
20012
|
+
address: import_joi14.default.string().required(),
|
|
20013
|
+
continuedAddress: import_joi14.default.string().optional().allow("", null),
|
|
20014
|
+
city: import_joi14.default.string().required(),
|
|
20015
|
+
province: import_joi14.default.string().required(),
|
|
20016
|
+
postalCode: import_joi14.default.string().required(),
|
|
20017
|
+
taxId: import_joi14.default.string().optional().allow("", null)
|
|
20003
20018
|
});
|
|
20004
20019
|
const { error } = validation.validate(value);
|
|
20005
20020
|
if (error) {
|
|
@@ -20016,7 +20031,7 @@ function useAddressController() {
|
|
|
20016
20031
|
}
|
|
20017
20032
|
async function getByUserId(req, res, next) {
|
|
20018
20033
|
const user = req.params.user;
|
|
20019
|
-
const validation =
|
|
20034
|
+
const validation = import_joi14.default.string().hex().required();
|
|
20020
20035
|
const { error } = validation.validate(user);
|
|
20021
20036
|
if (error) {
|
|
20022
20037
|
next(new import_utils65.BadRequestError(error.message));
|
|
@@ -20047,19 +20062,19 @@ var import_utils67 = require("@goweekdays/utils");
|
|
|
20047
20062
|
|
|
20048
20063
|
// src/models/member.model.ts
|
|
20049
20064
|
var import_utils66 = require("@goweekdays/utils");
|
|
20050
|
-
var
|
|
20065
|
+
var import_joi15 = __toESM(require("joi"));
|
|
20051
20066
|
var import_mongodb27 = require("mongodb");
|
|
20052
20067
|
function MMember(value) {
|
|
20053
|
-
const schema =
|
|
20054
|
-
_id:
|
|
20055
|
-
org:
|
|
20056
|
-
name:
|
|
20057
|
-
user:
|
|
20058
|
-
role:
|
|
20059
|
-
status:
|
|
20060
|
-
createdAt:
|
|
20061
|
-
updatedAt:
|
|
20062
|
-
deletedAt:
|
|
20068
|
+
const schema = import_joi15.default.object({
|
|
20069
|
+
_id: import_joi15.default.string().hex().optional().allow("", null),
|
|
20070
|
+
org: import_joi15.default.string().hex().required(),
|
|
20071
|
+
name: import_joi15.default.string().required(),
|
|
20072
|
+
user: import_joi15.default.string().hex().required(),
|
|
20073
|
+
role: import_joi15.default.string().hex().required(),
|
|
20074
|
+
status: import_joi15.default.string().optional().allow("", null),
|
|
20075
|
+
createdAt: import_joi15.default.string().optional().allow("", null),
|
|
20076
|
+
updatedAt: import_joi15.default.string().optional().allow("", null),
|
|
20077
|
+
deletedAt: import_joi15.default.string().optional().allow("", null)
|
|
20063
20078
|
});
|
|
20064
20079
|
const { error } = schema.validate(value);
|
|
20065
20080
|
if (error) {
|
|
@@ -20314,19 +20329,19 @@ function useOrgService() {
|
|
|
20314
20329
|
|
|
20315
20330
|
// src/controllers/organization.controller.ts
|
|
20316
20331
|
var import_utils69 = require("@goweekdays/utils");
|
|
20317
|
-
var
|
|
20332
|
+
var import_joi16 = __toESM(require("joi"));
|
|
20318
20333
|
function useOrgController() {
|
|
20319
20334
|
const { createOrg: _createOrg } = useOrgService();
|
|
20320
20335
|
const { getOrgsByUserId: _getOrgsByUserId } = useMemberRepo();
|
|
20321
20336
|
async function createOrg(req, res, next) {
|
|
20322
20337
|
const value = req.body;
|
|
20323
|
-
const validation =
|
|
20324
|
-
name:
|
|
20325
|
-
type:
|
|
20326
|
-
email:
|
|
20327
|
-
contact:
|
|
20328
|
-
description:
|
|
20329
|
-
user:
|
|
20338
|
+
const validation = import_joi16.default.object({
|
|
20339
|
+
name: import_joi16.default.string().required(),
|
|
20340
|
+
type: import_joi16.default.string().required(),
|
|
20341
|
+
email: import_joi16.default.string().email().required(),
|
|
20342
|
+
contact: import_joi16.default.string().required(),
|
|
20343
|
+
description: import_joi16.default.string().required(),
|
|
20344
|
+
user: import_joi16.default.string().hex().required()
|
|
20330
20345
|
});
|
|
20331
20346
|
const { error } = validation.validate(value);
|
|
20332
20347
|
if (error) {
|
|
@@ -20346,11 +20361,11 @@ function useOrgController() {
|
|
|
20346
20361
|
const limit = Number(req.query.limit) ?? 10;
|
|
20347
20362
|
const search = req.query.search ?? "";
|
|
20348
20363
|
const user = req.headers["user"];
|
|
20349
|
-
const validation =
|
|
20350
|
-
user:
|
|
20351
|
-
page:
|
|
20352
|
-
limit:
|
|
20353
|
-
search:
|
|
20364
|
+
const validation = import_joi16.default.object({
|
|
20365
|
+
user: import_joi16.default.string().hex().required(),
|
|
20366
|
+
page: import_joi16.default.number().min(1).optional().allow("", null),
|
|
20367
|
+
limit: import_joi16.default.number().min(1).optional().allow("", null),
|
|
20368
|
+
search: import_joi16.default.string().optional().allow("", null)
|
|
20354
20369
|
});
|
|
20355
20370
|
const { error } = validation.validate({ user, page, limit, search });
|
|
20356
20371
|
if (error) {
|