@goweekdays/core 1.1.6 → 1.1.7
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 +25 -29
- package/dist/index.js +143 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +180 -77
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -50,13 +50,13 @@ declare function useVerificationRepo(): {
|
|
|
50
50
|
type?: string | string[] | undefined;
|
|
51
51
|
email?: string | undefined;
|
|
52
52
|
app?: string | undefined;
|
|
53
|
-
}) => Promise<{
|
|
53
|
+
}) => Promise<TVerification[] | {
|
|
54
54
|
items: any[];
|
|
55
55
|
pages: number;
|
|
56
56
|
pageRange: string;
|
|
57
57
|
}>;
|
|
58
58
|
getById: (_id: ObjectId | string) => Promise<TVerification | null>;
|
|
59
|
-
getByIdByType: (type: string) => Promise<TVerification[][]>;
|
|
59
|
+
getByIdByType: (type: string) => Promise<TVerification[] | TVerification[][]>;
|
|
60
60
|
updateStatusById: (_id: ObjectId | string, status: string, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
|
|
61
61
|
};
|
|
62
62
|
|
|
@@ -80,7 +80,7 @@ declare function useVerificationService(): {
|
|
|
80
80
|
email?: string | undefined;
|
|
81
81
|
limit?: number | undefined;
|
|
82
82
|
app?: string | undefined;
|
|
83
|
-
}) => Promise<{
|
|
83
|
+
}) => Promise<TVerification[] | {
|
|
84
84
|
items: any[];
|
|
85
85
|
pages: number;
|
|
86
86
|
pageRange: string;
|
|
@@ -1234,11 +1234,7 @@ declare function useMemberRepo(): {
|
|
|
1234
1234
|
org?: string | ObjectId | undefined;
|
|
1235
1235
|
type: string;
|
|
1236
1236
|
status: string;
|
|
1237
|
-
}) => Promise<
|
|
1238
|
-
items: any[];
|
|
1239
|
-
pages: number;
|
|
1240
|
-
pageRange: string;
|
|
1241
|
-
} | TMember[]>;
|
|
1237
|
+
}) => Promise<Record<string, any>>;
|
|
1242
1238
|
getOrgsByUserId: ({ search, page, limit, sort, user, status, }?: {
|
|
1243
1239
|
user: string | ObjectId;
|
|
1244
1240
|
page: number;
|
|
@@ -1452,9 +1448,6 @@ declare const TInvoice: z.ZodObject<{
|
|
|
1452
1448
|
}, "strip", z.ZodTypeAny, {
|
|
1453
1449
|
type: "organization-subscription" | "affiliate-subscription" | "one-time-payment" | "other";
|
|
1454
1450
|
status: "pending" | "cancelled" | "paid" | "overdue";
|
|
1455
|
-
amount: number;
|
|
1456
|
-
invoiceNumber: string;
|
|
1457
|
-
dueDate: Date;
|
|
1458
1451
|
items: {
|
|
1459
1452
|
description: string;
|
|
1460
1453
|
unitPrice: number;
|
|
@@ -1462,6 +1455,9 @@ declare const TInvoice: z.ZodObject<{
|
|
|
1462
1455
|
total: number;
|
|
1463
1456
|
seats?: number | undefined;
|
|
1464
1457
|
}[];
|
|
1458
|
+
amount: number;
|
|
1459
|
+
invoiceNumber: string;
|
|
1460
|
+
dueDate: Date;
|
|
1465
1461
|
_id?: ObjectId | undefined;
|
|
1466
1462
|
updatedAt?: Date | undefined;
|
|
1467
1463
|
createdAt?: Date | undefined;
|
|
@@ -1475,9 +1471,6 @@ declare const TInvoice: z.ZodObject<{
|
|
|
1475
1471
|
billingCycle?: "monthly" | "yearly" | "quarterly" | undefined;
|
|
1476
1472
|
} | undefined;
|
|
1477
1473
|
}, {
|
|
1478
|
-
amount: number;
|
|
1479
|
-
invoiceNumber: string;
|
|
1480
|
-
dueDate: Date;
|
|
1481
1474
|
items: {
|
|
1482
1475
|
description: string;
|
|
1483
1476
|
unitPrice: number;
|
|
@@ -1485,6 +1478,9 @@ declare const TInvoice: z.ZodObject<{
|
|
|
1485
1478
|
total: number;
|
|
1486
1479
|
seats?: number | undefined;
|
|
1487
1480
|
}[];
|
|
1481
|
+
amount: number;
|
|
1482
|
+
invoiceNumber: string;
|
|
1483
|
+
dueDate: Date;
|
|
1488
1484
|
type?: "organization-subscription" | "affiliate-subscription" | "one-time-payment" | "other" | undefined;
|
|
1489
1485
|
status?: "pending" | "cancelled" | "paid" | "overdue" | undefined;
|
|
1490
1486
|
_id?: string | ObjectId | undefined;
|
|
@@ -1506,9 +1502,6 @@ declare function useInvoiceModel(db: Db): {
|
|
|
1506
1502
|
collection: Collection<{
|
|
1507
1503
|
type: "organization-subscription" | "affiliate-subscription" | "one-time-payment" | "other";
|
|
1508
1504
|
status: "pending" | "cancelled" | "paid" | "overdue";
|
|
1509
|
-
amount: number;
|
|
1510
|
-
invoiceNumber: string;
|
|
1511
|
-
dueDate: Date;
|
|
1512
1505
|
items: {
|
|
1513
1506
|
description: string;
|
|
1514
1507
|
unitPrice: number;
|
|
@@ -1516,6 +1509,9 @@ declare function useInvoiceModel(db: Db): {
|
|
|
1516
1509
|
total: number;
|
|
1517
1510
|
seats?: number | undefined;
|
|
1518
1511
|
}[];
|
|
1512
|
+
amount: number;
|
|
1513
|
+
invoiceNumber: string;
|
|
1514
|
+
dueDate: Date;
|
|
1519
1515
|
_id?: ObjectId | undefined;
|
|
1520
1516
|
updatedAt?: Date | undefined;
|
|
1521
1517
|
createdAt?: Date | undefined;
|
|
@@ -1538,9 +1534,6 @@ declare function useInvoiceRepo(): {
|
|
|
1538
1534
|
getByDueDate: (id: string | ObjectId, dueDate: Date, status?: TInvoice["status"]) => Promise<{
|
|
1539
1535
|
type: "organization-subscription" | "affiliate-subscription" | "one-time-payment" | "other";
|
|
1540
1536
|
status: "pending" | "cancelled" | "paid" | "overdue";
|
|
1541
|
-
amount: number;
|
|
1542
|
-
invoiceNumber: string;
|
|
1543
|
-
dueDate: Date;
|
|
1544
1537
|
items: {
|
|
1545
1538
|
description: string;
|
|
1546
1539
|
unitPrice: number;
|
|
@@ -1548,6 +1541,9 @@ declare function useInvoiceRepo(): {
|
|
|
1548
1541
|
total: number;
|
|
1549
1542
|
seats?: number | undefined;
|
|
1550
1543
|
}[];
|
|
1544
|
+
amount: number;
|
|
1545
|
+
invoiceNumber: string;
|
|
1546
|
+
dueDate: Date;
|
|
1551
1547
|
_id?: ObjectId | undefined;
|
|
1552
1548
|
updatedAt?: Date | undefined;
|
|
1553
1549
|
createdAt?: Date | undefined;
|
|
@@ -1565,9 +1561,6 @@ declare function useInvoiceRepo(): {
|
|
|
1565
1561
|
getOverdueInvoices: (BATCH_SIZE?: number) => Promise<{
|
|
1566
1562
|
type: "organization-subscription" | "affiliate-subscription" | "one-time-payment" | "other";
|
|
1567
1563
|
status: "pending" | "cancelled" | "paid" | "overdue";
|
|
1568
|
-
amount: number;
|
|
1569
|
-
invoiceNumber: string;
|
|
1570
|
-
dueDate: Date;
|
|
1571
1564
|
items: {
|
|
1572
1565
|
description: string;
|
|
1573
1566
|
unitPrice: number;
|
|
@@ -1575,6 +1568,9 @@ declare function useInvoiceRepo(): {
|
|
|
1575
1568
|
total: number;
|
|
1576
1569
|
seats?: number | undefined;
|
|
1577
1570
|
}[];
|
|
1571
|
+
amount: number;
|
|
1572
|
+
invoiceNumber: string;
|
|
1573
|
+
dueDate: Date;
|
|
1578
1574
|
_id?: ObjectId | undefined;
|
|
1579
1575
|
updatedAt?: Date | undefined;
|
|
1580
1576
|
createdAt?: Date | undefined;
|
|
@@ -1602,9 +1598,6 @@ declare function useInvoiceRepo(): {
|
|
|
1602
1598
|
getByNumber: (number: string) => Promise<{
|
|
1603
1599
|
type: "organization-subscription" | "affiliate-subscription" | "one-time-payment" | "other";
|
|
1604
1600
|
status: "pending" | "cancelled" | "paid" | "overdue";
|
|
1605
|
-
amount: number;
|
|
1606
|
-
invoiceNumber: string;
|
|
1607
|
-
dueDate: Date;
|
|
1608
1601
|
items: {
|
|
1609
1602
|
description: string;
|
|
1610
1603
|
unitPrice: number;
|
|
@@ -1612,6 +1605,9 @@ declare function useInvoiceRepo(): {
|
|
|
1612
1605
|
total: number;
|
|
1613
1606
|
seats?: number | undefined;
|
|
1614
1607
|
}[];
|
|
1608
|
+
amount: number;
|
|
1609
|
+
invoiceNumber: string;
|
|
1610
|
+
dueDate: Date;
|
|
1615
1611
|
_id?: ObjectId | undefined;
|
|
1616
1612
|
updatedAt?: Date | undefined;
|
|
1617
1613
|
createdAt?: Date | undefined;
|
|
@@ -1628,9 +1624,6 @@ declare function useInvoiceRepo(): {
|
|
|
1628
1624
|
getByTransactionId: (id: string) => Promise<{
|
|
1629
1625
|
type: "organization-subscription" | "affiliate-subscription" | "one-time-payment" | "other";
|
|
1630
1626
|
status: "pending" | "cancelled" | "paid" | "overdue";
|
|
1631
|
-
amount: number;
|
|
1632
|
-
invoiceNumber: string;
|
|
1633
|
-
dueDate: Date;
|
|
1634
1627
|
items: {
|
|
1635
1628
|
description: string;
|
|
1636
1629
|
unitPrice: number;
|
|
@@ -1638,6 +1631,9 @@ declare function useInvoiceRepo(): {
|
|
|
1638
1631
|
total: number;
|
|
1639
1632
|
seats?: number | undefined;
|
|
1640
1633
|
}[];
|
|
1634
|
+
amount: number;
|
|
1635
|
+
invoiceNumber: string;
|
|
1636
|
+
dueDate: Date;
|
|
1641
1637
|
_id?: ObjectId | undefined;
|
|
1642
1638
|
updatedAt?: Date | undefined;
|
|
1643
1639
|
createdAt?: Date | undefined;
|
package/dist/index.js
CHANGED
|
@@ -9973,6 +9973,7 @@ var require_es_set_tostringtag = __commonJS({
|
|
|
9973
9973
|
// node_modules/form-data/lib/populate.js
|
|
9974
9974
|
var require_populate = __commonJS({
|
|
9975
9975
|
"node_modules/form-data/lib/populate.js"(exports, module2) {
|
|
9976
|
+
"use strict";
|
|
9976
9977
|
module2.exports = function(dst, src) {
|
|
9977
9978
|
Object.keys(src).forEach(function(prop) {
|
|
9978
9979
|
dst[prop] = dst[prop] || src[prop];
|
|
@@ -9985,6 +9986,7 @@ var require_populate = __commonJS({
|
|
|
9985
9986
|
// node_modules/form-data/lib/form_data.js
|
|
9986
9987
|
var require_form_data = __commonJS({
|
|
9987
9988
|
"node_modules/form-data/lib/form_data.js"(exports, module2) {
|
|
9989
|
+
"use strict";
|
|
9988
9990
|
var CombinedStream = require_combined_stream();
|
|
9989
9991
|
var util3 = require("util");
|
|
9990
9992
|
var path = require("path");
|
|
@@ -9996,9 +9998,8 @@ var require_form_data = __commonJS({
|
|
|
9996
9998
|
var mime = require_mime_types();
|
|
9997
9999
|
var asynckit = require_asynckit();
|
|
9998
10000
|
var setToStringTag = require_es_set_tostringtag();
|
|
10001
|
+
var hasOwn = require_hasown();
|
|
9999
10002
|
var populate = require_populate();
|
|
10000
|
-
module2.exports = FormData3;
|
|
10001
|
-
util3.inherits(FormData3, CombinedStream);
|
|
10002
10003
|
function FormData3(options) {
|
|
10003
10004
|
if (!(this instanceof FormData3)) {
|
|
10004
10005
|
return new FormData3(options);
|
|
@@ -10012,16 +10013,17 @@ var require_form_data = __commonJS({
|
|
|
10012
10013
|
this[option] = options[option];
|
|
10013
10014
|
}
|
|
10014
10015
|
}
|
|
10016
|
+
util3.inherits(FormData3, CombinedStream);
|
|
10015
10017
|
FormData3.LINE_BREAK = "\r\n";
|
|
10016
10018
|
FormData3.DEFAULT_CONTENT_TYPE = "application/octet-stream";
|
|
10017
10019
|
FormData3.prototype.append = function(field, value, options) {
|
|
10018
10020
|
options = options || {};
|
|
10019
|
-
if (typeof options
|
|
10021
|
+
if (typeof options === "string") {
|
|
10020
10022
|
options = { filename: options };
|
|
10021
10023
|
}
|
|
10022
10024
|
var append2 = CombinedStream.prototype.append.bind(this);
|
|
10023
|
-
if (typeof value
|
|
10024
|
-
value =
|
|
10025
|
+
if (typeof value === "number" || value == null) {
|
|
10026
|
+
value = String(value);
|
|
10025
10027
|
}
|
|
10026
10028
|
if (Array.isArray(value)) {
|
|
10027
10029
|
this._error(new Error("Arrays are not supported."));
|
|
@@ -10037,7 +10039,7 @@ var require_form_data = __commonJS({
|
|
|
10037
10039
|
FormData3.prototype._trackLength = function(header, value, options) {
|
|
10038
10040
|
var valueLength = 0;
|
|
10039
10041
|
if (options.knownLength != null) {
|
|
10040
|
-
valueLength +=
|
|
10042
|
+
valueLength += Number(options.knownLength);
|
|
10041
10043
|
} else if (Buffer.isBuffer(value)) {
|
|
10042
10044
|
valueLength = value.length;
|
|
10043
10045
|
} else if (typeof value === "string") {
|
|
@@ -10045,7 +10047,7 @@ var require_form_data = __commonJS({
|
|
|
10045
10047
|
}
|
|
10046
10048
|
this._valueLength += valueLength;
|
|
10047
10049
|
this._overheadLength += Buffer.byteLength(header) + FormData3.LINE_BREAK.length;
|
|
10048
|
-
if (!value || !value.path && !(value.readable &&
|
|
10050
|
+
if (!value || !value.path && !(value.readable && hasOwn(value, "httpVersion")) && !(value instanceof Stream)) {
|
|
10049
10051
|
return;
|
|
10050
10052
|
}
|
|
10051
10053
|
if (!options.knownLength) {
|
|
@@ -10053,26 +10055,25 @@ var require_form_data = __commonJS({
|
|
|
10053
10055
|
}
|
|
10054
10056
|
};
|
|
10055
10057
|
FormData3.prototype._lengthRetriever = function(value, callback) {
|
|
10056
|
-
if (
|
|
10058
|
+
if (hasOwn(value, "fd")) {
|
|
10057
10059
|
if (value.end != void 0 && value.end != Infinity && value.start != void 0) {
|
|
10058
10060
|
callback(null, value.end + 1 - (value.start ? value.start : 0));
|
|
10059
10061
|
} else {
|
|
10060
10062
|
fs.stat(value.path, function(err, stat) {
|
|
10061
|
-
var fileSize;
|
|
10062
10063
|
if (err) {
|
|
10063
10064
|
callback(err);
|
|
10064
10065
|
return;
|
|
10065
10066
|
}
|
|
10066
|
-
fileSize = stat.size - (value.start ? value.start : 0);
|
|
10067
|
+
var fileSize = stat.size - (value.start ? value.start : 0);
|
|
10067
10068
|
callback(null, fileSize);
|
|
10068
10069
|
});
|
|
10069
10070
|
}
|
|
10070
|
-
} else if (
|
|
10071
|
-
callback(null,
|
|
10072
|
-
} else if (
|
|
10071
|
+
} else if (hasOwn(value, "httpVersion")) {
|
|
10072
|
+
callback(null, Number(value.headers["content-length"]));
|
|
10073
|
+
} else if (hasOwn(value, "httpModule")) {
|
|
10073
10074
|
value.on("response", function(response) {
|
|
10074
10075
|
value.pause();
|
|
10075
|
-
callback(null,
|
|
10076
|
+
callback(null, Number(response.headers["content-length"]));
|
|
10076
10077
|
});
|
|
10077
10078
|
value.resume();
|
|
10078
10079
|
} else {
|
|
@@ -10080,7 +10081,7 @@ var require_form_data = __commonJS({
|
|
|
10080
10081
|
}
|
|
10081
10082
|
};
|
|
10082
10083
|
FormData3.prototype._multiPartHeader = function(field, value, options) {
|
|
10083
|
-
if (typeof options.header
|
|
10084
|
+
if (typeof options.header === "string") {
|
|
10084
10085
|
return options.header;
|
|
10085
10086
|
}
|
|
10086
10087
|
var contentDisposition = this._getContentDisposition(value, options);
|
|
@@ -10092,12 +10093,12 @@ var require_form_data = __commonJS({
|
|
|
10092
10093
|
// if no content type. allow it to be empty array
|
|
10093
10094
|
"Content-Type": [].concat(contentType || [])
|
|
10094
10095
|
};
|
|
10095
|
-
if (typeof options.header
|
|
10096
|
+
if (typeof options.header === "object") {
|
|
10096
10097
|
populate(headers, options.header);
|
|
10097
10098
|
}
|
|
10098
10099
|
var header;
|
|
10099
10100
|
for (var prop in headers) {
|
|
10100
|
-
if (
|
|
10101
|
+
if (hasOwn(headers, prop)) {
|
|
10101
10102
|
header = headers[prop];
|
|
10102
10103
|
if (header == null) {
|
|
10103
10104
|
continue;
|
|
@@ -10113,34 +10114,33 @@ var require_form_data = __commonJS({
|
|
|
10113
10114
|
return "--" + this.getBoundary() + FormData3.LINE_BREAK + contents + FormData3.LINE_BREAK;
|
|
10114
10115
|
};
|
|
10115
10116
|
FormData3.prototype._getContentDisposition = function(value, options) {
|
|
10116
|
-
var filename
|
|
10117
|
+
var filename;
|
|
10117
10118
|
if (typeof options.filepath === "string") {
|
|
10118
10119
|
filename = path.normalize(options.filepath).replace(/\\/g, "/");
|
|
10119
|
-
} else if (options.filename || value.name || value.path) {
|
|
10120
|
-
filename = path.basename(options.filename || value.name || value.path);
|
|
10121
|
-
} else if (value.readable &&
|
|
10120
|
+
} else if (options.filename || value && (value.name || value.path)) {
|
|
10121
|
+
filename = path.basename(options.filename || value && (value.name || value.path));
|
|
10122
|
+
} else if (value && value.readable && hasOwn(value, "httpVersion")) {
|
|
10122
10123
|
filename = path.basename(value.client._httpMessage.path || "");
|
|
10123
10124
|
}
|
|
10124
10125
|
if (filename) {
|
|
10125
|
-
|
|
10126
|
+
return 'filename="' + filename + '"';
|
|
10126
10127
|
}
|
|
10127
|
-
return contentDisposition;
|
|
10128
10128
|
};
|
|
10129
10129
|
FormData3.prototype._getContentType = function(value, options) {
|
|
10130
10130
|
var contentType = options.contentType;
|
|
10131
|
-
if (!contentType && value.name) {
|
|
10131
|
+
if (!contentType && value && value.name) {
|
|
10132
10132
|
contentType = mime.lookup(value.name);
|
|
10133
10133
|
}
|
|
10134
|
-
if (!contentType && value.path) {
|
|
10134
|
+
if (!contentType && value && value.path) {
|
|
10135
10135
|
contentType = mime.lookup(value.path);
|
|
10136
10136
|
}
|
|
10137
|
-
if (!contentType && value.readable &&
|
|
10137
|
+
if (!contentType && value && value.readable && hasOwn(value, "httpVersion")) {
|
|
10138
10138
|
contentType = value.headers["content-type"];
|
|
10139
10139
|
}
|
|
10140
10140
|
if (!contentType && (options.filepath || options.filename)) {
|
|
10141
10141
|
contentType = mime.lookup(options.filepath || options.filename);
|
|
10142
10142
|
}
|
|
10143
|
-
if (!contentType && typeof value
|
|
10143
|
+
if (!contentType && value && typeof value === "object") {
|
|
10144
10144
|
contentType = FormData3.DEFAULT_CONTENT_TYPE;
|
|
10145
10145
|
}
|
|
10146
10146
|
return contentType;
|
|
@@ -10164,13 +10164,16 @@ var require_form_data = __commonJS({
|
|
|
10164
10164
|
"content-type": "multipart/form-data; boundary=" + this.getBoundary()
|
|
10165
10165
|
};
|
|
10166
10166
|
for (header in userHeaders) {
|
|
10167
|
-
if (
|
|
10167
|
+
if (hasOwn(userHeaders, header)) {
|
|
10168
10168
|
formHeaders[header.toLowerCase()] = userHeaders[header];
|
|
10169
10169
|
}
|
|
10170
10170
|
}
|
|
10171
10171
|
return formHeaders;
|
|
10172
10172
|
};
|
|
10173
10173
|
FormData3.prototype.setBoundary = function(boundary) {
|
|
10174
|
+
if (typeof boundary !== "string") {
|
|
10175
|
+
throw new TypeError("FormData boundary must be a string");
|
|
10176
|
+
}
|
|
10174
10177
|
this._boundary = boundary;
|
|
10175
10178
|
};
|
|
10176
10179
|
FormData3.prototype.getBoundary = function() {
|
|
@@ -10241,8 +10244,10 @@ var require_form_data = __commonJS({
|
|
|
10241
10244
|
});
|
|
10242
10245
|
};
|
|
10243
10246
|
FormData3.prototype.submit = function(params, cb) {
|
|
10244
|
-
var request
|
|
10245
|
-
|
|
10247
|
+
var request;
|
|
10248
|
+
var options;
|
|
10249
|
+
var defaults2 = { method: "post" };
|
|
10250
|
+
if (typeof params === "string") {
|
|
10246
10251
|
params = parseUrl(params);
|
|
10247
10252
|
options = populate({
|
|
10248
10253
|
port: params.port,
|
|
@@ -10253,11 +10258,11 @@ var require_form_data = __commonJS({
|
|
|
10253
10258
|
} else {
|
|
10254
10259
|
options = populate(params, defaults2);
|
|
10255
10260
|
if (!options.port) {
|
|
10256
|
-
options.port = options.protocol
|
|
10261
|
+
options.port = options.protocol === "https:" ? 443 : 80;
|
|
10257
10262
|
}
|
|
10258
10263
|
}
|
|
10259
10264
|
options.headers = this.getHeaders(params.headers);
|
|
10260
|
-
if (options.protocol
|
|
10265
|
+
if (options.protocol === "https:") {
|
|
10261
10266
|
request = https2.request(options);
|
|
10262
10267
|
} else {
|
|
10263
10268
|
request = http2.request(options);
|
|
@@ -10296,6 +10301,7 @@ var require_form_data = __commonJS({
|
|
|
10296
10301
|
return "[object FormData]";
|
|
10297
10302
|
};
|
|
10298
10303
|
setToStringTag(FormData3, "FormData");
|
|
10304
|
+
module2.exports = FormData3;
|
|
10299
10305
|
}
|
|
10300
10306
|
});
|
|
10301
10307
|
|
|
@@ -11460,7 +11466,22 @@ function useVerificationRepo() {
|
|
|
11460
11466
|
if (!db) {
|
|
11461
11467
|
throw new import_utils2.InternalServerError("Unable to connect to server.");
|
|
11462
11468
|
}
|
|
11463
|
-
const
|
|
11469
|
+
const namespace_collection = "verifications";
|
|
11470
|
+
const collection = db.collection(namespace_collection);
|
|
11471
|
+
const { getCache, setCache, delNamespace } = (0, import_utils2.useCache)();
|
|
11472
|
+
function delCachedData() {
|
|
11473
|
+
delNamespace(namespace_collection).then(() => {
|
|
11474
|
+
import_utils2.logger.log({
|
|
11475
|
+
level: "info",
|
|
11476
|
+
message: `Cache namespace cleared for ${namespace_collection}`
|
|
11477
|
+
});
|
|
11478
|
+
}).catch((err) => {
|
|
11479
|
+
import_utils2.logger.log({
|
|
11480
|
+
level: "error",
|
|
11481
|
+
message: `Failed to clear cache namespace for ${namespace_collection}: ${err.message}`
|
|
11482
|
+
});
|
|
11483
|
+
});
|
|
11484
|
+
}
|
|
11464
11485
|
async function createIndex() {
|
|
11465
11486
|
try {
|
|
11466
11487
|
await collection.createIndex([
|
|
@@ -11502,6 +11523,7 @@ function useVerificationRepo() {
|
|
|
11502
11523
|
value = new MVerification(value);
|
|
11503
11524
|
try {
|
|
11504
11525
|
const res = await collection.insertOne(value, { session });
|
|
11526
|
+
delCachedData();
|
|
11505
11527
|
return res.insertedId;
|
|
11506
11528
|
} catch (error) {
|
|
11507
11529
|
import_utils2.logger.log({ level: "error", message: `${error}` });
|
|
@@ -11524,7 +11546,30 @@ function useVerificationRepo() {
|
|
|
11524
11546
|
throw new import_utils2.BadRequestError("Invalid ID.");
|
|
11525
11547
|
}
|
|
11526
11548
|
try {
|
|
11527
|
-
|
|
11549
|
+
const cacheKey = (0, import_utils2.makeCacheKey)(namespace_collection, {
|
|
11550
|
+
id: _id.toString()
|
|
11551
|
+
});
|
|
11552
|
+
const cached = await getCache(cacheKey);
|
|
11553
|
+
if (cached) {
|
|
11554
|
+
import_utils2.logger.log({
|
|
11555
|
+
level: "info",
|
|
11556
|
+
message: `Cache hit for getById verification: ${cacheKey}`
|
|
11557
|
+
});
|
|
11558
|
+
return cached;
|
|
11559
|
+
}
|
|
11560
|
+
const data = await collection.findOne({ _id });
|
|
11561
|
+
setCache(cacheKey, data).then(() => {
|
|
11562
|
+
import_utils2.logger.log({
|
|
11563
|
+
level: "info",
|
|
11564
|
+
message: `Cache set for verification by id: ${cacheKey}`
|
|
11565
|
+
});
|
|
11566
|
+
}).catch((err) => {
|
|
11567
|
+
import_utils2.logger.log({
|
|
11568
|
+
level: "error",
|
|
11569
|
+
message: `Failed to set cache for verification by id: ${err.message}`
|
|
11570
|
+
});
|
|
11571
|
+
});
|
|
11572
|
+
return data;
|
|
11528
11573
|
} catch (error) {
|
|
11529
11574
|
throw new import_utils2.InternalServerError(
|
|
11530
11575
|
"Internal server error, failed to retrieve verification."
|
|
@@ -11543,20 +11588,36 @@ function useVerificationRepo() {
|
|
|
11543
11588
|
} = {}) {
|
|
11544
11589
|
page = page > 0 ? page - 1 : 0;
|
|
11545
11590
|
const query = { status };
|
|
11591
|
+
const cacheKeyOptions = { status, limit, page };
|
|
11546
11592
|
sort = Object.keys(sort).length > 0 ? sort : { _id: -1 };
|
|
11593
|
+
cacheKeyOptions.sort = JSON.stringify(sort);
|
|
11547
11594
|
if (app) {
|
|
11548
11595
|
query["metadata.app"] = app;
|
|
11596
|
+
cacheKeyOptions.app = app;
|
|
11549
11597
|
}
|
|
11550
11598
|
if (search) {
|
|
11551
11599
|
query.$text = { $search: search };
|
|
11600
|
+
cacheKeyOptions.search = search;
|
|
11552
11601
|
}
|
|
11553
11602
|
if (Array.isArray(type)) {
|
|
11554
11603
|
query.type = { $in: type };
|
|
11604
|
+
cacheKeyOptions.type = JSON.stringify(type);
|
|
11555
11605
|
} else if (type) {
|
|
11556
11606
|
query.type = type;
|
|
11607
|
+
cacheKeyOptions.type = type;
|
|
11557
11608
|
}
|
|
11558
11609
|
if (email) {
|
|
11559
11610
|
query.email = email;
|
|
11611
|
+
cacheKeyOptions.email = email;
|
|
11612
|
+
}
|
|
11613
|
+
const cacheKey = (0, import_utils2.makeCacheKey)(namespace_collection, cacheKeyOptions);
|
|
11614
|
+
const cached = await getCache(cacheKey);
|
|
11615
|
+
if (cached) {
|
|
11616
|
+
import_utils2.logger.log({
|
|
11617
|
+
level: "info",
|
|
11618
|
+
message: `Cache hit for getVerifications: ${cacheKey}`
|
|
11619
|
+
});
|
|
11620
|
+
return cached;
|
|
11560
11621
|
}
|
|
11561
11622
|
try {
|
|
11562
11623
|
const items = await collection.aggregate([
|
|
@@ -11576,7 +11637,19 @@ function useVerificationRepo() {
|
|
|
11576
11637
|
}
|
|
11577
11638
|
]).toArray();
|
|
11578
11639
|
const length = await collection.countDocuments(query);
|
|
11579
|
-
|
|
11640
|
+
const data = (0, import_utils2.paginate)(items, page, limit, length);
|
|
11641
|
+
setCache(cacheKey, data).then(() => {
|
|
11642
|
+
import_utils2.logger.log({
|
|
11643
|
+
level: "info",
|
|
11644
|
+
message: `Cache set for getVerifications: ${cacheKey}`
|
|
11645
|
+
});
|
|
11646
|
+
}).catch((err) => {
|
|
11647
|
+
import_utils2.logger.log({
|
|
11648
|
+
level: "error",
|
|
11649
|
+
message: `Failed to set cache for getVerifications: ${err.message}`
|
|
11650
|
+
});
|
|
11651
|
+
});
|
|
11652
|
+
return data;
|
|
11580
11653
|
} catch (error) {
|
|
11581
11654
|
import_utils2.logger.log({ level: "error", message: `${error}` });
|
|
11582
11655
|
throw error;
|
|
@@ -11584,7 +11657,30 @@ function useVerificationRepo() {
|
|
|
11584
11657
|
}
|
|
11585
11658
|
async function getByIdByType(type) {
|
|
11586
11659
|
try {
|
|
11587
|
-
|
|
11660
|
+
const cacheKey = (0, import_utils2.makeCacheKey)(namespace_collection, {
|
|
11661
|
+
type
|
|
11662
|
+
});
|
|
11663
|
+
const cached = await getCache(cacheKey);
|
|
11664
|
+
if (cached) {
|
|
11665
|
+
import_utils2.logger.log({
|
|
11666
|
+
level: "info",
|
|
11667
|
+
message: `Cache hit for getByIdByType verification: ${cacheKey}`
|
|
11668
|
+
});
|
|
11669
|
+
return cached;
|
|
11670
|
+
}
|
|
11671
|
+
const data = await collection.find({ type }).toArray();
|
|
11672
|
+
setCache(cacheKey, data).then(() => {
|
|
11673
|
+
import_utils2.logger.log({
|
|
11674
|
+
level: "info",
|
|
11675
|
+
message: `Cache set for verification by type: ${cacheKey}`
|
|
11676
|
+
});
|
|
11677
|
+
}).catch((err) => {
|
|
11678
|
+
import_utils2.logger.log({
|
|
11679
|
+
level: "error",
|
|
11680
|
+
message: `Failed to set cache for verification by type: ${err.message}`
|
|
11681
|
+
});
|
|
11682
|
+
});
|
|
11683
|
+
return data;
|
|
11588
11684
|
} catch (error) {
|
|
11589
11685
|
return Promise.reject(error);
|
|
11590
11686
|
}
|
|
@@ -11596,11 +11692,13 @@ function useVerificationRepo() {
|
|
|
11596
11692
|
throw new import_utils2.BadRequestError("Invalid ID.");
|
|
11597
11693
|
}
|
|
11598
11694
|
try {
|
|
11599
|
-
|
|
11695
|
+
const result = await collection.updateOne(
|
|
11600
11696
|
{ _id },
|
|
11601
11697
|
{ $set: { status, updatedAt: (/* @__PURE__ */ new Date()).toISOString() } },
|
|
11602
11698
|
{ session }
|
|
11603
11699
|
);
|
|
11700
|
+
delCachedData();
|
|
11701
|
+
return result;
|
|
11604
11702
|
} catch (error) {
|
|
11605
11703
|
throw new import_utils2.InternalServerError("Error updating verification status.");
|
|
11606
11704
|
}
|
|
@@ -12298,8 +12396,8 @@ function useMemberRepo() {
|
|
|
12298
12396
|
limit = limit > 0 ? limit : 10;
|
|
12299
12397
|
search = search || "";
|
|
12300
12398
|
page = page > 0 ? page - 1 : 0;
|
|
12301
|
-
const query = { type, status
|
|
12302
|
-
const cacheKeyOptions = { type, status };
|
|
12399
|
+
const query = { type, status };
|
|
12400
|
+
const cacheKeyOptions = { type, status, limit, page };
|
|
12303
12401
|
if (user) {
|
|
12304
12402
|
cacheKeyOptions.user = String(user);
|
|
12305
12403
|
try {
|
|
@@ -12326,7 +12424,7 @@ function useMemberRepo() {
|
|
|
12326
12424
|
message: `Cache key for getAll members: ${cacheKey}`
|
|
12327
12425
|
});
|
|
12328
12426
|
const cached = await getCache(cacheKey);
|
|
12329
|
-
if (cached) {
|
|
12427
|
+
if (cached && cached.items.length) {
|
|
12330
12428
|
import_utils5.logger.log({
|
|
12331
12429
|
level: "info",
|
|
12332
12430
|
message: `Cache hit for getAll members: ${cacheKey}`
|
|
@@ -13752,6 +13850,9 @@ function toFormData(obj, formData, options) {
|
|
|
13752
13850
|
if (utils_default.isDate(value)) {
|
|
13753
13851
|
return value.toISOString();
|
|
13754
13852
|
}
|
|
13853
|
+
if (utils_default.isBoolean(value)) {
|
|
13854
|
+
return value.toString();
|
|
13855
|
+
}
|
|
13755
13856
|
if (!useBlob && utils_default.isBlob(value)) {
|
|
13756
13857
|
throw new AxiosError_default("Blob is not supported. Use a Buffer instead.");
|
|
13757
13858
|
}
|
|
@@ -14538,7 +14639,7 @@ var import_follow_redirects = __toESM(require_follow_redirects(), 1);
|
|
|
14538
14639
|
var import_zlib = __toESM(require("zlib"), 1);
|
|
14539
14640
|
|
|
14540
14641
|
// node_modules/axios/lib/env/data.js
|
|
14541
|
-
var VERSION = "1.
|
|
14642
|
+
var VERSION = "1.10.0";
|
|
14542
14643
|
|
|
14543
14644
|
// node_modules/axios/lib/helpers/parseProtocol.js
|
|
14544
14645
|
function parseProtocol(url2) {
|
|
@@ -15953,7 +16054,7 @@ var fetch_default = isFetchSupported && (async (config2) => {
|
|
|
15953
16054
|
duplex: "half",
|
|
15954
16055
|
credentials: isCredentialsSupported ? withCredentials : void 0
|
|
15955
16056
|
});
|
|
15956
|
-
let response = await fetch(request);
|
|
16057
|
+
let response = await fetch(request, fetchOptions);
|
|
15957
16058
|
const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
|
|
15958
16059
|
if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
|
|
15959
16060
|
const options = {};
|