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.
@@ -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?: any[]) => {
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: any;
3
- body: any;
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 yup_config_1 = require("./../../yup.config");
9
- const paramId = (0, yup_config_1.object)({
10
- id: (0, yup_config_1.string)().required('id is required').oid('id is invalid')
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, yup_config_1.object)({
13
- translatedText: (0, yup_config_1.string)().required('translatedText is required'),
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;
@@ -1 +1,10 @@
1
- export default function (schema: any): any;
1
+ import yup from 'yup';
2
+ export default function (schema: {
3
+ [key: string]: any;
4
+ }): {
5
+ [key: string]: any;
6
+ } | yup.ObjectSchema<{
7
+ [x: string]: any;
8
+ }, yup.AnyObject, {
9
+ [x: string]: any;
10
+ }, "">;
@@ -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 yup_config_1 = __importDefault(require("./../yup.config"));
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 yup_config_1.default.object().shape(shape);
14
+ return yup_1.default.object().shape(shape);
15
15
  }
16
16
  return schema;
17
17
  }
@@ -0,0 +1,2 @@
1
+ import yup from "yup";
2
+ export default yup;
@@ -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;
@@ -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?: any[]) => {
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: any;
3
- body: any;
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 yup_config_1 = require("./../../yup.config");
9
- const paramId = (0, yup_config_1.object)({
10
- id: (0, yup_config_1.string)().required('id is required').oid('id is invalid')
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, yup_config_1.object)({
13
- translatedText: (0, yup_config_1.string)().required('translatedText is required'),
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;
@@ -1 +1,10 @@
1
- export default function (schema: any): any;
1
+ import yup from 'yup';
2
+ export default function (schema: {
3
+ [key: string]: any;
4
+ }): {
5
+ [key: string]: any;
6
+ } | yup.ObjectSchema<{
7
+ [x: string]: any;
8
+ }, yup.AnyObject, {
9
+ [x: string]: any;
10
+ }, "">;
@@ -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 yup_config_1 = __importDefault(require("./../yup.config"));
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 yup_config_1.default.object().shape(shape);
14
+ return yup_1.default.object().shape(shape);
15
15
  }
16
16
  return schema;
17
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speedly",
3
- "version": "1.2.30",
3
+ "version": "1.2.32",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/esm/index.d.ts",