@nocobase/database 1.7.0-alpha.11 → 1.7.0-alpha.13
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/lib/dialects/mariadb-dialect.d.ts +2 -0
- package/lib/dialects/mariadb-dialect.js +4 -0
- package/lib/fields/string-field.js +12 -2
- package/lib/fields/text-field.js +12 -2
- package/lib/interfaces/input-interface.d.ts +13 -0
- package/lib/interfaces/input-interface.js +61 -0
- package/lib/interfaces/utils.js +3 -1
- package/lib/view-collection.js +1 -1
- package/package.json +4 -4
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
import { DatabaseOptions } from '../database';
|
|
9
10
|
import { BaseDialect } from './base-dialect';
|
|
10
11
|
export declare class MariadbDialect extends BaseDialect {
|
|
11
12
|
static dialectName: string;
|
|
13
|
+
getSequelizeOptions(options: DatabaseOptions): import("../database").IDatabaseOptions;
|
|
12
14
|
getVersionGuard(): {
|
|
13
15
|
sql: string;
|
|
14
16
|
get: (v: string) => string;
|
|
@@ -34,6 +34,10 @@ __export(mariadb_dialect_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(mariadb_dialect_exports);
|
|
35
35
|
var import_base_dialect = require("./base-dialect");
|
|
36
36
|
const _MariadbDialect = class _MariadbDialect extends import_base_dialect.BaseDialect {
|
|
37
|
+
getSequelizeOptions(options) {
|
|
38
|
+
options.dialectOptions = { ...options.dialectOptions || {}, supportBigNumbers: true, bigNumberStrings: true };
|
|
39
|
+
return options;
|
|
40
|
+
}
|
|
37
41
|
getVersionGuard() {
|
|
38
42
|
return {
|
|
39
43
|
sql: "select version() as version",
|
|
@@ -40,10 +40,20 @@ const _StringField = class _StringField extends import_field.Field {
|
|
|
40
40
|
return import_sequelize.DataTypes.STRING;
|
|
41
41
|
}
|
|
42
42
|
additionalSequelizeOptions() {
|
|
43
|
-
const { name, trim } = this.options;
|
|
43
|
+
const { name, trim, unique } = this.options;
|
|
44
44
|
return {
|
|
45
45
|
set(value) {
|
|
46
|
-
|
|
46
|
+
if (unique && value === "") {
|
|
47
|
+
value = null;
|
|
48
|
+
}
|
|
49
|
+
if (value == null) {
|
|
50
|
+
this.setDataValue(name, null);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (typeof value !== "string") {
|
|
54
|
+
value = value.toString();
|
|
55
|
+
}
|
|
56
|
+
this.setDataValue(name, trim ? value.trim() : value);
|
|
47
57
|
}
|
|
48
58
|
};
|
|
49
59
|
}
|
package/lib/fields/text-field.js
CHANGED
|
@@ -45,10 +45,20 @@ const _TextField = class _TextField extends import_field.Field {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
additionalSequelizeOptions() {
|
|
48
|
-
const { name, trim } = this.options;
|
|
48
|
+
const { name, trim, unique } = this.options;
|
|
49
49
|
return {
|
|
50
50
|
set(value) {
|
|
51
|
-
|
|
51
|
+
if (unique && value === "") {
|
|
52
|
+
value = null;
|
|
53
|
+
}
|
|
54
|
+
if (value == null) {
|
|
55
|
+
this.setDataValue(name, null);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (typeof value !== "string") {
|
|
59
|
+
value = value.toString();
|
|
60
|
+
}
|
|
61
|
+
this.setDataValue(name, trim ? value.trim() : value);
|
|
52
62
|
}
|
|
53
63
|
};
|
|
54
64
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
import { BaseInterface } from './base-interface';
|
|
10
|
+
export declare class InputInterface extends BaseInterface {
|
|
11
|
+
toValue(value: any): any;
|
|
12
|
+
validate(value: any): boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
17
|
+
var __export = (target, all) => {
|
|
18
|
+
for (var name in all)
|
|
19
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
20
|
+
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var input_interface_exports = {};
|
|
39
|
+
__export(input_interface_exports, {
|
|
40
|
+
InputInterface: () => InputInterface
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(input_interface_exports);
|
|
43
|
+
var import_lodash = __toESM(require("lodash"));
|
|
44
|
+
var import_base_interface = require("./base-interface");
|
|
45
|
+
const _InputInterface = class _InputInterface extends import_base_interface.BaseInterface {
|
|
46
|
+
toValue(value) {
|
|
47
|
+
if (this.validate(value)) {
|
|
48
|
+
return value.toString();
|
|
49
|
+
}
|
|
50
|
+
throw new Error("Invalid value, expected string");
|
|
51
|
+
}
|
|
52
|
+
validate(value) {
|
|
53
|
+
return import_lodash.default.isString(value) || import_lodash.default.isNumber(value);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
__name(_InputInterface, "InputInterface");
|
|
57
|
+
let InputInterface = _InputInterface;
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
InputInterface
|
|
61
|
+
});
|
package/lib/interfaces/utils.js
CHANGED
|
@@ -39,6 +39,7 @@ var import_one_to_many_interface = require("./one-to-many-interface");
|
|
|
39
39
|
var import_integer_interface = require("./integer-interface");
|
|
40
40
|
var import_number_interface = require("./number-interface");
|
|
41
41
|
var import_json_interface = require("./json-interface");
|
|
42
|
+
var import_input_interface = require("./input-interface");
|
|
42
43
|
const interfaces = {
|
|
43
44
|
integer: import_integer_interface.IntegerInterface,
|
|
44
45
|
number: import_number_interface.NumberInterface,
|
|
@@ -63,7 +64,8 @@ const interfaces = {
|
|
|
63
64
|
o2m: import_one_to_many_interface.OneToManyInterface,
|
|
64
65
|
m2o: import_many_to_one_interface.ManyToOneInterface,
|
|
65
66
|
m2m: import_many_to_many_interface.ManyToManyInterface,
|
|
66
|
-
time: import_index.TimeInterface
|
|
67
|
+
time: import_index.TimeInterface,
|
|
68
|
+
input: import_input_interface.InputInterface
|
|
67
69
|
};
|
|
68
70
|
function registerInterfaces(db) {
|
|
69
71
|
for (const [interfaceName, type] of Object.entries(interfaces)) {
|
package/lib/view-collection.js
CHANGED
|
@@ -44,7 +44,7 @@ const _ViewCollection = class _ViewCollection extends import_collection.Collecti
|
|
|
44
44
|
if (this.options.writableView) {
|
|
45
45
|
return [];
|
|
46
46
|
}
|
|
47
|
-
return ["create", "update", "destroy"];
|
|
47
|
+
return ["create", "update", "destroy", "importXlsx", "destroyMany", "updateMany"];
|
|
48
48
|
}
|
|
49
49
|
sequelizeModelOptions() {
|
|
50
50
|
const modelOptions = super.sequelizeModelOptions();
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/database",
|
|
3
|
-
"version": "1.7.0-alpha.
|
|
3
|
+
"version": "1.7.0-alpha.13",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"license": "AGPL-3.0",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/logger": "1.7.0-alpha.
|
|
10
|
-
"@nocobase/utils": "1.7.0-alpha.
|
|
9
|
+
"@nocobase/logger": "1.7.0-alpha.13",
|
|
10
|
+
"@nocobase/utils": "1.7.0-alpha.13",
|
|
11
11
|
"async-mutex": "^0.3.2",
|
|
12
12
|
"chalk": "^4.1.1",
|
|
13
13
|
"cron-parser": "4.4.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
39
39
|
"directory": "packages/database"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "92281d435ef3c4c0a9b56d6d88405f8abc0a6cbf"
|
|
42
42
|
}
|