speedly 1.2.30 → 1.2.32
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/dist/cjs/db/db.d.ts +2 -2
- package/dist/cjs/modules/translation/translation.validator.d.ts +12 -2
- package/dist/cjs/modules/translation/translation.validator.js +5 -5
- package/dist/cjs/uploader/uploader.d.ts +1 -1
- package/dist/cjs/util/makeOptional.d.ts +10 -1
- package/dist/cjs/util/makeOptional.js +2 -2
- package/dist/cjs/yup.config.d.ts +2 -0
- package/dist/cjs/yup.config.js +24 -0
- package/dist/esm/db/db.d.ts +2 -2
- package/dist/esm/modules/translation/translation.validator.d.ts +12 -2
- package/dist/esm/modules/translation/translation.validator.js +5 -5
- package/dist/esm/uploader/uploader.d.ts +1 -1
- package/dist/esm/util/makeOptional.d.ts +10 -1
- package/dist/esm/util/makeOptional.js +2 -2
- package/package.json +1 -1
package/dist/cjs/db/db.d.ts
CHANGED
|
@@ -117,7 +117,7 @@ declare const db: (collectionName: string, config?: ConfigsType) => {
|
|
|
117
117
|
limit(value: number): /*elided*/ any;
|
|
118
118
|
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
119
119
|
};
|
|
120
|
-
aggregate: (pipeline?:
|
|
120
|
+
aggregate: (pipeline?: never[]) => {
|
|
121
121
|
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
122
122
|
select(value: string | {
|
|
123
123
|
[key: string]: -1 | 1;
|
|
@@ -177,5 +177,5 @@ declare const db: (collectionName: string, config?: ConfigsType) => {
|
|
|
177
177
|
limit(value: number): /*elided*/ any;
|
|
178
178
|
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
179
179
|
};
|
|
180
|
-
};
|
|
180
|
+
} | undefined;
|
|
181
181
|
export default db;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
declare const put: {
|
|
2
|
-
params:
|
|
3
|
-
|
|
2
|
+
params: import("yup").ObjectSchema<{
|
|
3
|
+
id: string;
|
|
4
|
+
}, import("yup").AnyObject, {
|
|
5
|
+
id: undefined;
|
|
6
|
+
}, "">;
|
|
7
|
+
body: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
} | import("yup").ObjectSchema<{
|
|
10
|
+
[x: string]: any;
|
|
11
|
+
}, import("yup").AnyObject, {
|
|
12
|
+
[x: string]: any;
|
|
13
|
+
}, "">;
|
|
4
14
|
};
|
|
5
15
|
export { put };
|
|
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.put = void 0;
|
|
7
7
|
const makeOptional_1 = __importDefault(require("../../util/makeOptional"));
|
|
8
|
-
const
|
|
9
|
-
const paramId = (0,
|
|
10
|
-
id: (0,
|
|
8
|
+
const yup_1 = require("yup");
|
|
9
|
+
const paramId = (0, yup_1.object)({
|
|
10
|
+
id: (0, yup_1.string)().required('id is required').matches(/^[0-9a-fA-F]{24}$/, 'id is invalid')
|
|
11
11
|
});
|
|
12
|
-
const schema = (0,
|
|
13
|
-
translatedText: (0,
|
|
12
|
+
const schema = (0, yup_1.object)({
|
|
13
|
+
translatedText: (0, yup_1.string)().required('translatedText is required'),
|
|
14
14
|
});
|
|
15
15
|
//? exports
|
|
16
16
|
const put = {
|
|
@@ -20,5 +20,5 @@ declare const _default: (destination?: string | ((req: Request, file: Express.Mu
|
|
|
20
20
|
fields: (fields: multer.Field[]) => (req: Request, res: Response, next: NextFunction) => void;
|
|
21
21
|
any: () => (req: Request, res: Response, next: NextFunction) => void;
|
|
22
22
|
none: () => (req: Request, res: Response, next: NextFunction) => void;
|
|
23
|
-
};
|
|
23
|
+
} | undefined;
|
|
24
24
|
export default _default;
|
|
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = default_1;
|
|
7
|
-
const
|
|
7
|
+
const yup_1 = __importDefault(require("yup"));
|
|
8
8
|
function default_1(schema) {
|
|
9
9
|
if (schema.fields) {
|
|
10
10
|
const shape = {};
|
|
11
11
|
for (const key in schema.fields) {
|
|
12
12
|
shape[key] = schema.fields[key].optional();
|
|
13
13
|
}
|
|
14
|
-
return
|
|
14
|
+
return yup_1.default.object().shape(shape);
|
|
15
15
|
}
|
|
16
16
|
return schema;
|
|
17
17
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const mongoose_1 = require("mongoose");
|
|
7
|
+
const yup_1 = __importDefault(require("yup"));
|
|
8
|
+
yup_1.default.addMethod(yup_1.default.string, "oid", function (errorMessage = "آیدی درست نیست") {
|
|
9
|
+
return this.test({
|
|
10
|
+
name: "oid",
|
|
11
|
+
message: errorMessage,
|
|
12
|
+
test(value) {
|
|
13
|
+
if (!value)
|
|
14
|
+
return true;
|
|
15
|
+
if (value == "$$REMOVE")
|
|
16
|
+
return true;
|
|
17
|
+
if (!value || !(0, mongoose_1.isValidObjectId)(value)) {
|
|
18
|
+
return false; // Invalid ObjectId
|
|
19
|
+
}
|
|
20
|
+
return true; // Valid ObjectId
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
exports.default = yup_1.default;
|
package/dist/esm/db/db.d.ts
CHANGED
|
@@ -117,7 +117,7 @@ declare const db: (collectionName: string, config?: ConfigsType) => {
|
|
|
117
117
|
limit(value: number): /*elided*/ any;
|
|
118
118
|
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
119
119
|
};
|
|
120
|
-
aggregate: (pipeline?:
|
|
120
|
+
aggregate: (pipeline?: never[]) => {
|
|
121
121
|
(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
122
122
|
select(value: string | {
|
|
123
123
|
[key: string]: -1 | 1;
|
|
@@ -177,5 +177,5 @@ declare const db: (collectionName: string, config?: ConfigsType) => {
|
|
|
177
177
|
limit(value: number): /*elided*/ any;
|
|
178
178
|
populate(value: string | object | (string | object)[]): /*elided*/ any;
|
|
179
179
|
};
|
|
180
|
-
};
|
|
180
|
+
} | undefined;
|
|
181
181
|
export default db;
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
declare const put: {
|
|
2
|
-
params:
|
|
3
|
-
|
|
2
|
+
params: import("yup").ObjectSchema<{
|
|
3
|
+
id: string;
|
|
4
|
+
}, import("yup").AnyObject, {
|
|
5
|
+
id: undefined;
|
|
6
|
+
}, "">;
|
|
7
|
+
body: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
} | import("yup").ObjectSchema<{
|
|
10
|
+
[x: string]: any;
|
|
11
|
+
}, import("yup").AnyObject, {
|
|
12
|
+
[x: string]: any;
|
|
13
|
+
}, "">;
|
|
4
14
|
};
|
|
5
15
|
export { put };
|
|
@@ -5,12 +5,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.put = void 0;
|
|
7
7
|
const makeOptional_1 = __importDefault(require("../../util/makeOptional"));
|
|
8
|
-
const
|
|
9
|
-
const paramId = (0,
|
|
10
|
-
id: (0,
|
|
8
|
+
const yup_1 = require("yup");
|
|
9
|
+
const paramId = (0, yup_1.object)({
|
|
10
|
+
id: (0, yup_1.string)().required('id is required').matches(/^[0-9a-fA-F]{24}$/, 'id is invalid')
|
|
11
11
|
});
|
|
12
|
-
const schema = (0,
|
|
13
|
-
translatedText: (0,
|
|
12
|
+
const schema = (0, yup_1.object)({
|
|
13
|
+
translatedText: (0, yup_1.string)().required('translatedText is required'),
|
|
14
14
|
});
|
|
15
15
|
//? exports
|
|
16
16
|
const put = {
|
|
@@ -20,5 +20,5 @@ declare const _default: (destination?: string | ((req: Request, file: Express.Mu
|
|
|
20
20
|
fields: (fields: multer.Field[]) => (req: Request, res: Response, next: NextFunction) => void;
|
|
21
21
|
any: () => (req: Request, res: Response, next: NextFunction) => void;
|
|
22
22
|
none: () => (req: Request, res: Response, next: NextFunction) => void;
|
|
23
|
-
};
|
|
23
|
+
} | undefined;
|
|
24
24
|
export default _default;
|
|
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = default_1;
|
|
7
|
-
const
|
|
7
|
+
const yup_1 = __importDefault(require("yup"));
|
|
8
8
|
function default_1(schema) {
|
|
9
9
|
if (schema.fields) {
|
|
10
10
|
const shape = {};
|
|
11
11
|
for (const key in schema.fields) {
|
|
12
12
|
shape[key] = schema.fields[key].optional();
|
|
13
13
|
}
|
|
14
|
-
return
|
|
14
|
+
return yup_1.default.object().shape(shape);
|
|
15
15
|
}
|
|
16
16
|
return schema;
|
|
17
17
|
}
|