speedly 1.2.32 → 1.2.34
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 +1 -0
- package/dist/cjs/db/db.js +4 -2
- package/dist/cjs/util/makeOptional.d.ts +1 -1
- package/dist/cjs/util/makeOptional.js +35 -5
- package/dist/esm/db/db.d.ts +1 -0
- package/dist/esm/db/db.js +4 -2
- package/dist/esm/util/makeOptional.d.ts +1 -1
- package/dist/esm/util/makeOptional.js +35 -5
- package/package.json +1 -1
package/dist/cjs/db/db.d.ts
CHANGED
package/dist/cjs/db/db.js
CHANGED
|
@@ -11,17 +11,18 @@ const translator_1 = __importDefault(require("../util/translator"));
|
|
|
11
11
|
let configs = {
|
|
12
12
|
dbType: "mongodb",
|
|
13
13
|
path: "../models",
|
|
14
|
+
type: 'external',
|
|
14
15
|
dbEnv: "DB_URL",
|
|
15
16
|
...(0, getConfig_1.default)("db"),
|
|
16
17
|
};
|
|
17
|
-
const usingMongoDb = (collectionName, config = {}) => {
|
|
18
|
+
const usingMongoDb = (collectionName, config = { type: 'external' }) => {
|
|
18
19
|
let model;
|
|
19
20
|
let queryState = {
|
|
20
21
|
queries: [],
|
|
21
22
|
};
|
|
22
23
|
if (config?.path)
|
|
23
24
|
__path = config.path;
|
|
24
|
-
model = require(path_1.default.join(require.main?.filename || './', __path, collectionName));
|
|
25
|
+
model = require(path_1.default.join(...(config.type == 'external' ? [require.main?.filename || './', __path] : ['../model']), collectionName));
|
|
25
26
|
const actionHandler = {
|
|
26
27
|
find: (match = {}) => {
|
|
27
28
|
queryState.action = "find";
|
|
@@ -470,6 +471,7 @@ const db = (collectionName, config = configs) => {
|
|
|
470
471
|
dbType: "mongodb",
|
|
471
472
|
path: "../models",
|
|
472
473
|
dbEnv: "DB_URL",
|
|
474
|
+
type: 'external',
|
|
473
475
|
...(0, getConfig_1.default)("db"),
|
|
474
476
|
};
|
|
475
477
|
Object.entries(config).forEach(([key, value]) => {
|
|
@@ -1,17 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
5
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
36
|
exports.default = default_1;
|
|
7
|
-
const
|
|
37
|
+
const yup = __importStar(require("yup"));
|
|
8
38
|
function default_1(schema) {
|
|
9
39
|
if (schema.fields) {
|
|
10
40
|
const shape = {};
|
|
11
41
|
for (const key in schema.fields) {
|
|
12
42
|
shape[key] = schema.fields[key].optional();
|
|
13
43
|
}
|
|
14
|
-
return
|
|
44
|
+
return yup.object().shape(shape);
|
|
15
45
|
}
|
|
16
46
|
return schema;
|
|
17
47
|
}
|
package/dist/esm/db/db.d.ts
CHANGED
package/dist/esm/db/db.js
CHANGED
|
@@ -11,17 +11,18 @@ const translator_1 = __importDefault(require("../util/translator"));
|
|
|
11
11
|
let configs = {
|
|
12
12
|
dbType: "mongodb",
|
|
13
13
|
path: "../models",
|
|
14
|
+
type: 'external',
|
|
14
15
|
dbEnv: "DB_URL",
|
|
15
16
|
...(0, getConfig_1.default)("db"),
|
|
16
17
|
};
|
|
17
|
-
const usingMongoDb = (collectionName, config = {}) => {
|
|
18
|
+
const usingMongoDb = (collectionName, config = { type: 'external' }) => {
|
|
18
19
|
let model;
|
|
19
20
|
let queryState = {
|
|
20
21
|
queries: [],
|
|
21
22
|
};
|
|
22
23
|
if (config?.path)
|
|
23
24
|
__path = config.path;
|
|
24
|
-
model = require(path_1.default.join(require.main?.filename || './', __path, collectionName));
|
|
25
|
+
model = require(path_1.default.join(...(config.type == 'external' ? [require.main?.filename || './', __path] : ['../model']), collectionName));
|
|
25
26
|
const actionHandler = {
|
|
26
27
|
find: (match = {}) => {
|
|
27
28
|
queryState.action = "find";
|
|
@@ -470,6 +471,7 @@ const db = (collectionName, config = configs) => {
|
|
|
470
471
|
dbType: "mongodb",
|
|
471
472
|
path: "../models",
|
|
472
473
|
dbEnv: "DB_URL",
|
|
474
|
+
type: 'external',
|
|
473
475
|
...(0, getConfig_1.default)("db"),
|
|
474
476
|
};
|
|
475
477
|
Object.entries(config).forEach(([key, value]) => {
|
|
@@ -1,17 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
5
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
36
|
exports.default = default_1;
|
|
7
|
-
const
|
|
37
|
+
const yup = __importStar(require("yup"));
|
|
8
38
|
function default_1(schema) {
|
|
9
39
|
if (schema.fields) {
|
|
10
40
|
const shape = {};
|
|
11
41
|
for (const key in schema.fields) {
|
|
12
42
|
shape[key] = schema.fields[key].optional();
|
|
13
43
|
}
|
|
14
|
-
return
|
|
44
|
+
return yup.object().shape(shape);
|
|
15
45
|
}
|
|
16
46
|
return schema;
|
|
17
47
|
}
|