@nocobase/data-source-manager 2.0.10 → 2.0.12
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.
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { DataSource } from './data-source';
|
|
10
|
-
import { CollectionOptions, ICollection, ICollectionManager, IFieldInterface, IRepository, MergeOptions } from './types';
|
|
10
|
+
import { CollectionOptions, ICollection, ICollectionManager, IField, IFieldInterface, IRepository, MergeOptions } from './types';
|
|
11
11
|
export declare class CollectionManager implements ICollectionManager {
|
|
12
12
|
dataSource: DataSource;
|
|
13
13
|
protected collections: Map<string, ICollection>;
|
|
@@ -25,6 +25,7 @@ export declare class CollectionManager implements ICollectionManager {
|
|
|
25
25
|
getFieldInterface(name: string): {
|
|
26
26
|
new (options: any): IFieldInterface | undefined;
|
|
27
27
|
};
|
|
28
|
+
isNumericField(field?: IField): boolean;
|
|
28
29
|
registerCollectionTemplates(): void;
|
|
29
30
|
registerModels(models: Record<string, any>): void;
|
|
30
31
|
registerRepositories(repositories: Record<string, any>): void;
|
|
@@ -32,6 +32,7 @@ __export(collection_manager_exports, {
|
|
|
32
32
|
module.exports = __toCommonJS(collection_manager_exports);
|
|
33
33
|
var import_collection = require("./collection");
|
|
34
34
|
var import_repository = require("./repository");
|
|
35
|
+
var import_utils = require("./utils");
|
|
35
36
|
const _CollectionManager = class _CollectionManager {
|
|
36
37
|
dataSource;
|
|
37
38
|
collections = /* @__PURE__ */ new Map();
|
|
@@ -77,6 +78,9 @@ const _CollectionManager = class _CollectionManager {
|
|
|
77
78
|
getFieldInterface(name) {
|
|
78
79
|
return;
|
|
79
80
|
}
|
|
81
|
+
isNumericField(field) {
|
|
82
|
+
return (0, import_utils.isNumericField)(field);
|
|
83
|
+
}
|
|
80
84
|
/* istanbul ignore next -- @preserve */
|
|
81
85
|
registerCollectionTemplates() {
|
|
82
86
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { Database } from '@nocobase/database';
|
|
10
10
|
import { DataSource } from './data-source';
|
|
11
|
-
import { CollectionOptions, ICollection, ICollectionManager, IFieldInterface, IRepository, MergeOptions } from './types';
|
|
11
|
+
import { CollectionOptions, ICollection, ICollectionManager, IField, IFieldInterface, IRepository, MergeOptions } from './types';
|
|
12
12
|
export declare class SequelizeCollectionManager implements ICollectionManager {
|
|
13
13
|
db: Database;
|
|
14
14
|
options: any;
|
|
@@ -35,4 +35,5 @@ export declare class SequelizeCollectionManager implements ICollectionManager {
|
|
|
35
35
|
getFieldInterface(name: string): {
|
|
36
36
|
new (options: any): IFieldInterface | undefined;
|
|
37
37
|
};
|
|
38
|
+
isNumericField(field?: IField): boolean;
|
|
38
39
|
}
|
|
@@ -31,6 +31,7 @@ __export(sequelize_collection_manager_exports, {
|
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(sequelize_collection_manager_exports);
|
|
33
33
|
var import_database = require("@nocobase/database");
|
|
34
|
+
var import_utils = require("./utils");
|
|
34
35
|
/* istanbul ignore file -- @preserve */
|
|
35
36
|
const _SequelizeCollectionManager = class _SequelizeCollectionManager {
|
|
36
37
|
db;
|
|
@@ -109,6 +110,9 @@ const _SequelizeCollectionManager = class _SequelizeCollectionManager {
|
|
|
109
110
|
getFieldInterface(name) {
|
|
110
111
|
return this.db.interfaceManager.getInterfaceType(name);
|
|
111
112
|
}
|
|
113
|
+
isNumericField(field) {
|
|
114
|
+
return (0, import_utils.isNumericField)(field);
|
|
115
|
+
}
|
|
112
116
|
};
|
|
113
117
|
__name(_SequelizeCollectionManager, "SequelizeCollectionManager");
|
|
114
118
|
let SequelizeCollectionManager = _SequelizeCollectionManager;
|
package/lib/types.d.ts
CHANGED
|
@@ -102,6 +102,7 @@ export interface ICollectionManager {
|
|
|
102
102
|
registerFieldInterfaces(interfaces: Record<string, new (options: any) => IFieldInterface>): void;
|
|
103
103
|
registerFieldInterface(name: string, fieldInterface: new (options: any) => IFieldInterface): void;
|
|
104
104
|
getFieldInterface(name: string): new (options: any) => IFieldInterface | undefined;
|
|
105
|
+
isNumericField(field?: IField): boolean;
|
|
105
106
|
registerCollectionTemplates(templates: Record<string, any>): void;
|
|
106
107
|
registerModels(models: Record<string, any>): void;
|
|
107
108
|
registerRepositories(repositories: Record<string, new (collection: ICollection) => IRepository>): void;
|
package/lib/utils.d.ts
CHANGED
|
@@ -8,3 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function parseCollectionName(collection: string): string[];
|
|
10
10
|
export declare function joinCollectionName(dataSourceName: string, collectionName: string): string;
|
|
11
|
+
export declare function isNumericField(field?: {
|
|
12
|
+
options?: {
|
|
13
|
+
type?: string;
|
|
14
|
+
};
|
|
15
|
+
}): boolean;
|
package/lib/utils.js
CHANGED
|
@@ -27,6 +27,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
var utils_exports = {};
|
|
29
29
|
__export(utils_exports, {
|
|
30
|
+
isNumericField: () => isNumericField,
|
|
30
31
|
joinCollectionName: () => joinCollectionName,
|
|
31
32
|
parseCollectionName: () => parseCollectionName
|
|
32
33
|
});
|
|
@@ -48,8 +49,16 @@ function joinCollectionName(dataSourceName, collectionName) {
|
|
|
48
49
|
return `${dataSourceName}:${collectionName}`;
|
|
49
50
|
}
|
|
50
51
|
__name(joinCollectionName, "joinCollectionName");
|
|
52
|
+
const NUMERIC_FIELD_TYPES = /* @__PURE__ */ new Set(["integer", "bigInt", "float", "double", "decimal"]);
|
|
53
|
+
function isNumericField(field) {
|
|
54
|
+
var _a;
|
|
55
|
+
const fieldType = (_a = field == null ? void 0 : field.options) == null ? void 0 : _a.type;
|
|
56
|
+
return typeof fieldType === "string" && NUMERIC_FIELD_TYPES.has(fieldType);
|
|
57
|
+
}
|
|
58
|
+
__name(isNumericField, "isNumericField");
|
|
51
59
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
60
|
0 && (module.exports = {
|
|
61
|
+
isNumericField,
|
|
53
62
|
joinCollectionName,
|
|
54
63
|
parseCollectionName
|
|
55
64
|
});
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/data-source-manager",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.12",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/actions": "2.0.
|
|
10
|
-
"@nocobase/cache": "2.0.
|
|
11
|
-
"@nocobase/database": "2.0.
|
|
12
|
-
"@nocobase/resourcer": "2.0.
|
|
13
|
-
"@nocobase/utils": "2.0.
|
|
9
|
+
"@nocobase/actions": "2.0.12",
|
|
10
|
+
"@nocobase/cache": "2.0.12",
|
|
11
|
+
"@nocobase/database": "2.0.12",
|
|
12
|
+
"@nocobase/resourcer": "2.0.12",
|
|
13
|
+
"@nocobase/utils": "2.0.12",
|
|
14
14
|
"@types/jsonwebtoken": "^8.5.8",
|
|
15
15
|
"jsonwebtoken": "^9.0.2"
|
|
16
16
|
},
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
20
20
|
"directory": "packages/auth"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "a96acd22a9b0744b567617e3a1f1d42cb7f72368"
|
|
23
23
|
}
|