speedly 1.2.24 → 1.2.28

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.
@@ -1,3 +1 @@
1
- declare const string: any, object: any, array: any, lazy: any;
2
- declare const paramId: any;
3
- declare const schema: any;
1
+ export {};
@@ -1,14 +1,18 @@
1
- // const makeOptional = require("../../util/makeOptional");
2
- // import makeOptional from '../../util/'
3
- const { string, object, array, lazy } = require("../../yup.config");
4
- const paramId = object({
5
- id: string().required('id is required').oid('id is invalid')
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 makeOptional_1 = __importDefault(require("../../util/makeOptional"));
7
+ const yup_config_1 = require("./../../yup.config");
8
+ const paramId = (0, yup_config_1.object)({
9
+ id: (0, yup_config_1.string)().required('id is required').oid('id is invalid')
6
10
  });
7
- const schema = object({
8
- translatedText: string().required('translatedText is required'),
11
+ const schema = (0, yup_config_1.object)({
12
+ translatedText: (0, yup_config_1.string)().required('translatedText is required'),
9
13
  });
10
14
  //? exports
11
15
  exports.put = {
12
16
  params: paramId,
13
- // body : makeOptional(schema)
17
+ body: (0, makeOptional_1.default)(schema)
14
18
  };
@@ -38,7 +38,7 @@ exports.default = (destination = "/image", config = configs) => {
38
38
  fs_1.default.mkdirSync(currentPath);
39
39
  }
40
40
  });
41
- cb(null, path_1.default.join(require.main.filename || '', configs.path, dest));
41
+ cb(null, path_1.default.join(configs.path, dest));
42
42
  }
43
43
  catch (err) {
44
44
  cb(err, "");
@@ -53,7 +53,7 @@ exports.default = (destination = "/image", config = configs) => {
53
53
  const originalName = Buffer.from(file.originalname, "latin1").toString("utf8");
54
54
  const fileName = (configs.prefix ? configs.prefix + "-" : "") +
55
55
  originalName.replace(/\.\w+$/, "") + ext;
56
- const filePath = path_1.default.join(require.main.filename || '', configs.path, dest, fileName);
56
+ const filePath = path_1.default.join(configs.path, dest, fileName);
57
57
  console.log('uploader', 65, filePath);
58
58
  try {
59
59
  fs_1.default.existsSync(filePath);
@@ -103,7 +103,7 @@ exports.default = (destination = "/image", config = configs) => {
103
103
  req.mediaId = mediaDoc.insertedId;
104
104
  }
105
105
  req.body[fieldName] = path_1.default
106
- .join("/static", path_1.default.relative(path_1.default.join(require.main.filename || '', configs.path), req.file.path))
106
+ .join("/static", path_1.default.relative(path_1.default.join(configs.path), req.file.path))
107
107
  .replaceAll(/\\/g, "/");
108
108
  }
109
109
  next();
@@ -115,7 +115,7 @@ exports.default = (destination = "/image", config = configs) => {
115
115
  return res.status(405).json({ message: err.message });
116
116
  if (req.files && Array.isArray(req.files) && req.files.length) {
117
117
  req.body[fieldName] = req.files.map(file => path_1.default
118
- .join("/static", path_1.default.relative(path_1.default.join(require.main.filename || '', configs.path), file.path))
118
+ .join("/static", path_1.default.relative(path_1.default.join(configs.path), file.path))
119
119
  .replaceAll(/\\/g, "/"));
120
120
  }
121
121
  next();
@@ -0,0 +1 @@
1
+ export default function (schema: any): any;
@@ -0,0 +1,17 @@
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
+ exports.default = default_1;
7
+ const yup_config_1 = __importDefault(require("./../yup.config"));
8
+ function default_1(schema) {
9
+ if (schema.fields) {
10
+ const shape = {};
11
+ for (const key in schema.fields) {
12
+ shape[key] = schema.fields[key].optional();
13
+ }
14
+ return yup_config_1.default.object().shape(shape);
15
+ }
16
+ return schema;
17
+ }
@@ -1,16 +1,18 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // const makeOptional = require("../../util/makeOptional");
4
- // import makeOptional from '../../util/'
5
- const { string, object, array, lazy } = require("../../yup.config");
6
- const paramId = object({
7
- id: string().required('id is required').oid('id is invalid')
6
+ const makeOptional_1 = __importDefault(require("../../util/makeOptional"));
7
+ const yup_config_1 = require("./../../yup.config");
8
+ const paramId = (0, yup_config_1.object)({
9
+ id: (0, yup_config_1.string)().required('id is required').oid('id is invalid')
8
10
  });
9
- const schema = object({
10
- translatedText: string().required('translatedText is required'),
11
+ const schema = (0, yup_config_1.object)({
12
+ translatedText: (0, yup_config_1.string)().required('translatedText is required'),
11
13
  });
12
14
  //? exports
13
15
  exports.put = {
14
16
  params: paramId,
15
- // body : makeOptional(schema)
17
+ body: (0, makeOptional_1.default)(schema)
16
18
  };
@@ -38,7 +38,7 @@ exports.default = (destination = "/image", config = configs) => {
38
38
  fs_1.default.mkdirSync(currentPath);
39
39
  }
40
40
  });
41
- cb(null, path_1.default.join(require.main.filename || '', configs.path, dest));
41
+ cb(null, path_1.default.join(configs.path, dest));
42
42
  }
43
43
  catch (err) {
44
44
  cb(err, "");
@@ -53,7 +53,7 @@ exports.default = (destination = "/image", config = configs) => {
53
53
  const originalName = Buffer.from(file.originalname, "latin1").toString("utf8");
54
54
  const fileName = (configs.prefix ? configs.prefix + "-" : "") +
55
55
  originalName.replace(/\.\w+$/, "") + ext;
56
- const filePath = path_1.default.join(require.main.filename || '', configs.path, dest, fileName);
56
+ const filePath = path_1.default.join(configs.path, dest, fileName);
57
57
  console.log('uploader', 65, filePath);
58
58
  try {
59
59
  fs_1.default.existsSync(filePath);
@@ -103,7 +103,7 @@ exports.default = (destination = "/image", config = configs) => {
103
103
  req.mediaId = mediaDoc.insertedId;
104
104
  }
105
105
  req.body[fieldName] = path_1.default
106
- .join("/static", path_1.default.relative(path_1.default.join(require.main.filename || '', configs.path), req.file.path))
106
+ .join("/static", path_1.default.relative(path_1.default.join(configs.path), req.file.path))
107
107
  .replaceAll(/\\/g, "/");
108
108
  }
109
109
  next();
@@ -115,7 +115,7 @@ exports.default = (destination = "/image", config = configs) => {
115
115
  return res.status(405).json({ message: err.message });
116
116
  if (req.files && Array.isArray(req.files) && req.files.length) {
117
117
  req.body[fieldName] = req.files.map(file => path_1.default
118
- .join("/static", path_1.default.relative(path_1.default.join(require.main.filename || '', configs.path), file.path))
118
+ .join("/static", path_1.default.relative(path_1.default.join(configs.path), file.path))
119
119
  .replaceAll(/\\/g, "/"));
120
120
  }
121
121
  next();
@@ -0,0 +1 @@
1
+ export default function (schema: any): any;
@@ -0,0 +1,17 @@
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
+ exports.default = default_1;
7
+ const yup_config_1 = __importDefault(require("./../yup.config"));
8
+ function default_1(schema) {
9
+ if (schema.fields) {
10
+ const shape = {};
11
+ for (const key in schema.fields) {
12
+ shape[key] = schema.fields[key].optional();
13
+ }
14
+ return yup_config_1.default.object().shape(shape);
15
+ }
16
+ return schema;
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speedly",
3
- "version": "1.2.24",
3
+ "version": "1.2.28",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/esm/index.d.ts",