@nocobase/database 1.2.13-alpha → 1.3.0-alpha.20240710084543
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/package.json +4 -4
- package/lib/collection-factory.d.ts +0 -25
- package/lib/collection-factory.js +0 -61
- package/lib/collection-group-manager.d.ts +0 -34
- package/lib/collection-group-manager.js +0 -66
- package/lib/collection-importer.d.ts +0 -15
- package/lib/collection-importer.js +0 -83
- package/lib/collection.d.ts +0 -145
- package/lib/collection.js +0 -663
- package/lib/database-utils/index.d.ts +0 -16
- package/lib/database-utils/index.js +0 -75
- package/lib/database.d.ts +0 -228
- package/lib/database.js +0 -795
- package/lib/decorators/must-have-filter-decorator.d.ts +0 -10
- package/lib/decorators/must-have-filter-decorator.js +0 -48
- package/lib/decorators/target-collection-decorator.d.ts +0 -10
- package/lib/decorators/target-collection-decorator.js +0 -56
- package/lib/decorators/transaction-decorator.d.ts +0 -9
- package/lib/decorators/transaction-decorator.js +0 -95
- package/lib/eager-loading/eager-loading-tree.d.ts +0 -39
- package/lib/eager-loading/eager-loading-tree.js +0 -448
- package/lib/errors/identifier-error.d.ts +0 -11
- package/lib/errors/identifier-error.js +0 -44
- package/lib/errors/zero-column-table-error.d.ts +0 -10
- package/lib/errors/zero-column-table-error.js +0 -40
- package/lib/features/references-map.d.ts +0 -29
- package/lib/features/references-map.js +0 -120
- package/lib/features/referential-integrity-check.d.ts +0 -16
- package/lib/features/referential-integrity-check.js +0 -86
- package/lib/field-repository/array-field-repository.d.ts +0 -36
- package/lib/field-repository/array-field-repository.js +0 -179
- package/lib/fields/array-field.d.ts +0 -19
- package/lib/fields/array-field.js +0 -66
- package/lib/fields/belongs-to-field.d.ts +0 -25
- package/lib/fields/belongs-to-field.js +0 -166
- package/lib/fields/belongs-to-many-field.d.ts +0 -28
- package/lib/fields/belongs-to-many-field.js +0 -196
- package/lib/fields/boolean-field.d.ts +0 -16
- package/lib/fields/boolean-field.js +0 -45
- package/lib/fields/context-field.d.ts +0 -22
- package/lib/fields/context-field.js +0 -79
- package/lib/fields/date-field.d.ts +0 -21
- package/lib/fields/date-field.js +0 -73
- package/lib/fields/field.d.ts +0 -52
- package/lib/fields/field.js +0 -168
- package/lib/fields/has-inverse-field.d.ts +0 -12
- package/lib/fields/has-inverse-field.js +0 -24
- package/lib/fields/has-many-field.d.ts +0 -76
- package/lib/fields/has-many-field.js +0 -165
- package/lib/fields/has-one-field.d.ts +0 -76
- package/lib/fields/has-one-field.js +0 -159
- package/lib/fields/index.d.ts +0 -54
- package/lib/fields/index.js +0 -74
- package/lib/fields/json-field.d.ts +0 -22
- package/lib/fields/json-field.js +0 -63
- package/lib/fields/nanoid-field.d.ts +0 -22
- package/lib/fields/nanoid-field.js +0 -65
- package/lib/fields/number-field.d.ts +0 -49
- package/lib/fields/number-field.js +0 -94
- package/lib/fields/password-field.d.ts +0 -29
- package/lib/fields/password-field.js +0 -106
- package/lib/fields/radio-field.d.ts +0 -24
- package/lib/fields/radio-field.js +0 -75
- package/lib/fields/relation-field.d.ts +0 -31
- package/lib/fields/relation-field.js +0 -94
- package/lib/fields/set-field.d.ts +0 -18
- package/lib/fields/set-field.js +0 -55
- package/lib/fields/sort-field.d.ts +0 -22
- package/lib/fields/sort-field.js +0 -197
- package/lib/fields/string-field.d.ts +0 -16
- package/lib/fields/string-field.js +0 -45
- package/lib/fields/text-field.d.ts +0 -18
- package/lib/fields/text-field.js +0 -53
- package/lib/fields/time-field.d.ts +0 -16
- package/lib/fields/time-field.js +0 -45
- package/lib/fields/uid-field.d.ts +0 -21
- package/lib/fields/uid-field.js +0 -72
- package/lib/fields/uuid-field.d.ts +0 -20
- package/lib/fields/uuid-field.js +0 -63
- package/lib/fields/virtual-field.d.ts +0 -16
- package/lib/fields/virtual-field.js +0 -45
- package/lib/filter-match.d.ts +0 -9
- package/lib/filter-match.js +0 -75
- package/lib/filter-parser.d.ts +0 -29
- package/lib/filter-parser.js +0 -238
- package/lib/helpers.d.ts +0 -11
- package/lib/helpers.js +0 -182
- package/lib/index.d.ts +0 -37
- package/lib/index.js +0 -138
- package/lib/inherited-collection.d.ts +0 -22
- package/lib/inherited-collection.js +0 -147
- package/lib/inherited-map.d.ts +0 -29
- package/lib/inherited-map.js +0 -125
- package/lib/inherited-sync-runner.d.ts +0 -12
- package/lib/inherited-sync-runner.js +0 -184
- package/lib/interface-manager.d.ts +0 -17
- package/lib/interface-manager.js +0 -50
- package/lib/interfaces/base-interface.d.ts +0 -33
- package/lib/interfaces/base-interface.js +0 -80
- package/lib/interfaces/boolean-interface.d.ts +0 -13
- package/lib/interfaces/boolean-interface.js +0 -70
- package/lib/interfaces/checkboxes-interface.d.ts +0 -11
- package/lib/interfaces/checkboxes-interface.js +0 -41
- package/lib/interfaces/datetime-interface.d.ts +0 -13
- package/lib/interfaces/datetime-interface.js +0 -108
- package/lib/interfaces/index.d.ts +0 -14
- package/lib/interfaces/index.js +0 -40
- package/lib/interfaces/integer-interface.d.ts +0 -12
- package/lib/interfaces/integer-interface.js +0 -44
- package/lib/interfaces/json-interface.d.ts +0 -13
- package/lib/interfaces/json-interface.js +0 -47
- package/lib/interfaces/many-to-many-interface.d.ts +0 -11
- package/lib/interfaces/many-to-many-interface.js +0 -41
- package/lib/interfaces/many-to-one-interface.d.ts +0 -11
- package/lib/interfaces/many-to-one-interface.js +0 -41
- package/lib/interfaces/multiple-select-interface.d.ts +0 -13
- package/lib/interfaces/multiple-select-interface.js +0 -76
- package/lib/interfaces/number-interface.d.ts +0 -15
- package/lib/interfaces/number-interface.js +0 -72
- package/lib/interfaces/one-belongs-to-one-interface.d.ts +0 -11
- package/lib/interfaces/one-belongs-to-one-interface.js +0 -41
- package/lib/interfaces/one-has-one-interface.d.ts +0 -11
- package/lib/interfaces/one-has-one-interface.js +0 -41
- package/lib/interfaces/one-to-many-interface.d.ts +0 -11
- package/lib/interfaces/one-to-many-interface.js +0 -41
- package/lib/interfaces/percent-interface.d.ts +0 -13
- package/lib/interfaces/percent-interface.js +0 -55
- package/lib/interfaces/select-interface.d.ts +0 -13
- package/lib/interfaces/select-interface.js +0 -63
- package/lib/interfaces/to-many-interface.d.ts +0 -12
- package/lib/interfaces/to-many-interface.js +0 -61
- package/lib/interfaces/to-one-interface.d.ts +0 -13
- package/lib/interfaces/to-one-interface.js +0 -61
- package/lib/interfaces/utils.d.ts +0 -10
- package/lib/interfaces/utils.js +0 -72
- package/lib/listeners/adjacency-list.d.ts +0 -10
- package/lib/listeners/adjacency-list.js +0 -51
- package/lib/listeners/append-child-collection-name-after-repository-find.d.ts +0 -14
- package/lib/listeners/append-child-collection-name-after-repository-find.js +0 -75
- package/lib/listeners/index.d.ts +0 -10
- package/lib/listeners/index.js +0 -42
- package/lib/magic-attribute-model.d.ts +0 -16
- package/lib/magic-attribute-model.js +0 -213
- package/lib/migration.d.ts +0 -43
- package/lib/migration.js +0 -112
- package/lib/mock-database.d.ts +0 -33
- package/lib/mock-database.js +0 -136
- package/lib/model-hook.d.ts +0 -20
- package/lib/model-hook.js +0 -96
- package/lib/model.d.ts +0 -32
- package/lib/model.js +0 -179
- package/lib/operators/array.d.ts +0 -10
- package/lib/operators/array.js +0 -196
- package/lib/operators/association.d.ts +0 -10
- package/lib/operators/association.js +0 -44
- package/lib/operators/boolean.d.ts +0 -10
- package/lib/operators/boolean.js +0 -47
- package/lib/operators/child-collection.d.ts +0 -10
- package/lib/operators/child-collection.js +0 -77
- package/lib/operators/date.d.ts +0 -10
- package/lib/operators/date.js +0 -149
- package/lib/operators/empty.d.ts +0 -13
- package/lib/operators/empty.js +0 -102
- package/lib/operators/eq.d.ts +0 -10
- package/lib/operators/eq.js +0 -44
- package/lib/operators/index.d.ts +0 -13
- package/lib/operators/index.js +0 -63
- package/lib/operators/ne.d.ts +0 -10
- package/lib/operators/ne.js +0 -49
- package/lib/operators/notIn.d.ts +0 -10
- package/lib/operators/notIn.js +0 -42
- package/lib/operators/string.d.ts +0 -10
- package/lib/operators/string.js +0 -118
- package/lib/operators/utils.d.ts +0 -12
- package/lib/operators/utils.js +0 -53
- package/lib/options-parser.d.ts +0 -45
- package/lib/options-parser.js +0 -350
- package/lib/query-interface/mysql-query-interface.d.ts +0 -44
- package/lib/query-interface/mysql-query-interface.js +0 -134
- package/lib/query-interface/postgres-query-interface.d.ts +0 -41
- package/lib/query-interface/postgres-query-interface.js +0 -207
- package/lib/query-interface/query-interface-builder.d.ts +0 -10
- package/lib/query-interface/query-interface-builder.js +0 -55
- package/lib/query-interface/query-interface.d.ts +0 -52
- package/lib/query-interface/query-interface.js +0 -59
- package/lib/query-interface/sqlite-query-interface.d.ts +0 -44
- package/lib/query-interface/sqlite-query-interface.js +0 -141
- package/lib/relation-repository/belongs-to-many-repository.d.ts +0 -28
- package/lib/relation-repository/belongs-to-many-repository.js +0 -248
- package/lib/relation-repository/belongs-to-repository.d.ts +0 -17
- package/lib/relation-repository/belongs-to-repository.js +0 -51
- package/lib/relation-repository/hasmany-repository.d.ts +0 -21
- package/lib/relation-repository/hasmany-repository.js +0 -158
- package/lib/relation-repository/hasone-repository.d.ts +0 -17
- package/lib/relation-repository/hasone-repository.js +0 -51
- package/lib/relation-repository/multiple-relation-repository.d.ts +0 -27
- package/lib/relation-repository/multiple-relation-repository.js +0 -200
- package/lib/relation-repository/relation-repository.d.ts +0 -38
- package/lib/relation-repository/relation-repository.js +0 -175
- package/lib/relation-repository/single-relation-repository.d.ts +0 -36
- package/lib/relation-repository/single-relation-repository.js +0 -151
- package/lib/relation-repository/types.d.ts +0 -15
- package/lib/relation-repository/types.js +0 -24
- package/lib/repositories/tree-repository/adjacency-list-repository.d.ts +0 -26
- package/lib/repositories/tree-repository/adjacency-list-repository.js +0 -192
- package/lib/repositories/view-repository.d.ts +0 -11
- package/lib/repositories/view-repository.js +0 -41
- package/lib/repository.d.ts +0 -214
- package/lib/repository.js +0 -609
- package/lib/sql-parser/index.d.ts +0 -13
- package/lib/sql-parser/index.js +0 -33
- package/lib/sync-runner.d.ts +0 -41
- package/lib/sync-runner.js +0 -335
- package/lib/types.d.ts +0 -57
- package/lib/types.js +0 -24
- package/lib/update-associations.d.ts +0 -68
- package/lib/update-associations.js +0 -429
- package/lib/update-guard.d.ts +0 -36
- package/lib/update-guard.js +0 -212
- package/lib/utils.d.ts +0 -15
- package/lib/utils.js +0 -136
- package/lib/value-parsers/array-value-parser.d.ts +0 -16
- package/lib/value-parsers/array-value-parser.js +0 -67
- package/lib/value-parsers/base-value-parser.d.ts +0 -20
- package/lib/value-parsers/base-value-parser.js +0 -72
- package/lib/value-parsers/boolean-value-parser.d.ts +0 -12
- package/lib/value-parsers/boolean-value-parser.js +0 -61
- package/lib/value-parsers/date-value-parser.d.ts +0 -13
- package/lib/value-parsers/date-value-parser.js +0 -99
- package/lib/value-parsers/index.d.ts +0 -20
- package/lib/value-parsers/index.js +0 -87
- package/lib/value-parsers/json-value-parser.d.ts +0 -12
- package/lib/value-parsers/json-value-parser.js +0 -56
- package/lib/value-parsers/number-value-parser.d.ts +0 -12
- package/lib/value-parsers/number-value-parser.js +0 -67
- package/lib/value-parsers/string-value-parser.d.ts +0 -16
- package/lib/value-parsers/string-value-parser.js +0 -73
- package/lib/value-parsers/to-many-value-parser.d.ts +0 -21
- package/lib/value-parsers/to-many-value-parser.js +0 -117
- package/lib/value-parsers/to-one-value-parser.d.ts +0 -12
- package/lib/value-parsers/to-one-value-parser.js +0 -57
- package/lib/view/field-type-map.d.ts +0 -109
- package/lib/view/field-type-map.js +0 -101
- package/lib/view/view-inference.d.ts +0 -40
- package/lib/view/view-inference.js +0 -157
- package/lib/view-collection.d.ts +0 -14
- package/lib/view-collection.js +0 -54
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/database",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-alpha.20240710084543",
|
|
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.
|
|
10
|
-
"@nocobase/utils": "1.
|
|
9
|
+
"@nocobase/logger": "1.3.0-alpha.20240710084543",
|
|
10
|
+
"@nocobase/utils": "1.3.0-alpha.20240710084543",
|
|
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": "07a8b596fc64a9779a194cb9b0dc2ca7570ed9d4"
|
|
42
42
|
}
|
|
@@ -1,25 +0,0 @@
|
|
|
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 { Collection, CollectionOptions } from './collection';
|
|
10
|
-
import Database from './database';
|
|
11
|
-
import { Model } from './model';
|
|
12
|
-
type CollectionTypeOptions = {
|
|
13
|
-
condition: (options: CollectionOptions) => boolean;
|
|
14
|
-
onSync?: (model: typeof Model, options: any) => Promise<void>;
|
|
15
|
-
onDump?: (dumper: any, collection: Collection) => Promise<void>;
|
|
16
|
-
};
|
|
17
|
-
export declare class CollectionFactory {
|
|
18
|
-
private database;
|
|
19
|
-
collectionTypes: Map<typeof Collection, CollectionTypeOptions>;
|
|
20
|
-
constructor(database: Database);
|
|
21
|
-
registerCollectionType(collectionClass: typeof Collection, // Using the collection class as the key
|
|
22
|
-
options: CollectionTypeOptions): void;
|
|
23
|
-
createCollection<T extends Collection>(collectionOptions: CollectionOptions): T;
|
|
24
|
-
}
|
|
25
|
-
export {};
|
|
@@ -1,61 +0,0 @@
|
|
|
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 __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
-
var __export = (target, all) => {
|
|
16
|
-
for (var name in all)
|
|
17
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
-
};
|
|
19
|
-
var __copyProps = (to, from, except, desc) => {
|
|
20
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
-
for (let key of __getOwnPropNames(from))
|
|
22
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var collection_factory_exports = {};
|
|
29
|
-
__export(collection_factory_exports, {
|
|
30
|
-
CollectionFactory: () => CollectionFactory
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(collection_factory_exports);
|
|
33
|
-
var import_collection = require("./collection");
|
|
34
|
-
const _CollectionFactory = class _CollectionFactory {
|
|
35
|
-
constructor(database) {
|
|
36
|
-
this.database = database;
|
|
37
|
-
}
|
|
38
|
-
// Using a Map with the collection subclass as the key and options as the value
|
|
39
|
-
collectionTypes = /* @__PURE__ */ new Map();
|
|
40
|
-
registerCollectionType(collectionClass, options) {
|
|
41
|
-
this.collectionTypes.set(collectionClass, options);
|
|
42
|
-
}
|
|
43
|
-
createCollection(collectionOptions) {
|
|
44
|
-
let klass = import_collection.Collection;
|
|
45
|
-
for (const [ctor, options] of this.collectionTypes) {
|
|
46
|
-
if (options.condition(collectionOptions)) {
|
|
47
|
-
klass = ctor;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return new klass(collectionOptions, {
|
|
52
|
-
database: this.database
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
__name(_CollectionFactory, "CollectionFactory");
|
|
57
|
-
let CollectionFactory = _CollectionFactory;
|
|
58
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
-
0 && (module.exports = {
|
|
60
|
-
CollectionFactory
|
|
61
|
-
});
|
|
@@ -1,34 +0,0 @@
|
|
|
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 { BaseDumpRules, DumpRules } from './collection';
|
|
10
|
-
import Database from './database';
|
|
11
|
-
type RequiredGroup = 'required';
|
|
12
|
-
type SkippedGroup = 'skipped';
|
|
13
|
-
export type BuiltInGroup = RequiredGroup | SkippedGroup;
|
|
14
|
-
export type DumpRulesGroupType = BuiltInGroup | string;
|
|
15
|
-
export interface CollectionGroup {
|
|
16
|
-
collections: string[];
|
|
17
|
-
function: string;
|
|
18
|
-
dataType: DumpRulesGroupType;
|
|
19
|
-
delayRestore?: any;
|
|
20
|
-
}
|
|
21
|
-
export interface CollectionGroupWithCollectionTitle extends Omit<CollectionGroup, 'collections'> {
|
|
22
|
-
collections: Array<{
|
|
23
|
-
name: string;
|
|
24
|
-
title: string;
|
|
25
|
-
}>;
|
|
26
|
-
}
|
|
27
|
-
export declare class CollectionGroupManager {
|
|
28
|
-
db: Database;
|
|
29
|
-
constructor(db: Database);
|
|
30
|
-
static unifyDumpRules(dumpRules: DumpRules): (BaseDumpRules & {
|
|
31
|
-
group: DumpRulesGroupType;
|
|
32
|
-
}) | undefined;
|
|
33
|
-
}
|
|
34
|
-
export {};
|
|
@@ -1,66 +0,0 @@
|
|
|
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 __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
-
var __export = (target, all) => {
|
|
16
|
-
for (var name in all)
|
|
17
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
-
};
|
|
19
|
-
var __copyProps = (to, from, except, desc) => {
|
|
20
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
-
for (let key of __getOwnPropNames(from))
|
|
22
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var collection_group_manager_exports = {};
|
|
29
|
-
__export(collection_group_manager_exports, {
|
|
30
|
-
CollectionGroupManager: () => CollectionGroupManager
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(collection_group_manager_exports);
|
|
33
|
-
const _CollectionGroupManager = class _CollectionGroupManager {
|
|
34
|
-
constructor(db) {
|
|
35
|
-
this.db = db;
|
|
36
|
-
}
|
|
37
|
-
static unifyDumpRules(dumpRules) {
|
|
38
|
-
if (!dumpRules) {
|
|
39
|
-
return void 0;
|
|
40
|
-
}
|
|
41
|
-
if (typeof dumpRules === "string") {
|
|
42
|
-
return {
|
|
43
|
-
group: dumpRules
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
if ("required" in dumpRules && dumpRules.required) {
|
|
47
|
-
return {
|
|
48
|
-
...dumpRules,
|
|
49
|
-
group: "required"
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
if ("skipped" in dumpRules && dumpRules.skipped) {
|
|
53
|
-
return {
|
|
54
|
-
...dumpRules,
|
|
55
|
-
group: "skipped"
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
return dumpRules;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
__name(_CollectionGroupManager, "CollectionGroupManager");
|
|
62
|
-
let CollectionGroupManager = _CollectionGroupManager;
|
|
63
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
-
0 && (module.exports = {
|
|
65
|
-
CollectionGroupManager
|
|
66
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
-
export type ImportFileExtension = 'js' | 'ts' | 'json';
|
|
10
|
-
export declare class ImporterReader {
|
|
11
|
-
directory: string;
|
|
12
|
-
extensions: Set<string>;
|
|
13
|
-
constructor(directory: string, extensions?: ImportFileExtension[]);
|
|
14
|
-
read(): Promise<any[]>;
|
|
15
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
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 collection_importer_exports = {};
|
|
39
|
-
__export(collection_importer_exports, {
|
|
40
|
-
ImporterReader: () => ImporterReader
|
|
41
|
-
});
|
|
42
|
-
module.exports = __toCommonJS(collection_importer_exports);
|
|
43
|
-
var import_utils = require("@nocobase/utils");
|
|
44
|
-
var import_fs = require("fs");
|
|
45
|
-
var import_promises = require("fs/promises");
|
|
46
|
-
var import_lodash = require("lodash");
|
|
47
|
-
var import_path = __toESM(require("path"));
|
|
48
|
-
const _ImporterReader = class _ImporterReader {
|
|
49
|
-
directory;
|
|
50
|
-
extensions;
|
|
51
|
-
constructor(directory, extensions) {
|
|
52
|
-
this.directory = directory;
|
|
53
|
-
if (!extensions) {
|
|
54
|
-
extensions = ["js", "ts", "json"];
|
|
55
|
-
}
|
|
56
|
-
this.extensions = new Set(extensions);
|
|
57
|
-
}
|
|
58
|
-
async read() {
|
|
59
|
-
if (!(0, import_fs.existsSync)(this.directory)) {
|
|
60
|
-
return [];
|
|
61
|
-
}
|
|
62
|
-
const files = await (0, import_promises.readdir)(this.directory, {
|
|
63
|
-
encoding: "utf-8"
|
|
64
|
-
});
|
|
65
|
-
const modules = files.filter((fileName) => {
|
|
66
|
-
if (fileName.endsWith(".d.ts")) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
const ext = import_path.default.parse(fileName).ext.replace(".", "");
|
|
70
|
-
return this.extensions.has(ext);
|
|
71
|
-
}).map(async (fileName) => {
|
|
72
|
-
const mod = await (0, import_utils.importModule)(import_path.default.join(this.directory, fileName));
|
|
73
|
-
return typeof mod === "function" ? mod() : mod;
|
|
74
|
-
});
|
|
75
|
-
return (await Promise.all(modules)).filter((module2) => (0, import_lodash.isPlainObject)(module2)).map((module2) => (0, import_lodash.cloneDeep)(module2));
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
__name(_ImporterReader, "ImporterReader");
|
|
79
|
-
let ImporterReader = _ImporterReader;
|
|
80
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
-
0 && (module.exports = {
|
|
82
|
-
ImporterReader
|
|
83
|
-
});
|
package/lib/collection.d.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
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
|
-
/// <reference types="node" />
|
|
10
|
-
import { EventEmitter } from 'events';
|
|
11
|
-
import { ModelOptions, ModelStatic, QueryInterfaceDropTableOptions, QueryInterfaceOptions, SyncOptions, Transactionable } from 'sequelize';
|
|
12
|
-
import { BuiltInGroup } from './collection-group-manager';
|
|
13
|
-
import { Database } from './database';
|
|
14
|
-
import { BelongsToField, Field, FieldOptions, HasManyField } from './fields';
|
|
15
|
-
import { Model } from './model';
|
|
16
|
-
import { Repository } from './repository';
|
|
17
|
-
export type RepositoryType = typeof Repository;
|
|
18
|
-
export type CollectionSortable = string | boolean | {
|
|
19
|
-
name?: string;
|
|
20
|
-
scopeKey?: string;
|
|
21
|
-
};
|
|
22
|
-
export type BaseDumpRules = {
|
|
23
|
-
delayRestore?: any;
|
|
24
|
-
};
|
|
25
|
-
export type DumpRules = BuiltInGroup | ({
|
|
26
|
-
required: true;
|
|
27
|
-
} & BaseDumpRules) | ({
|
|
28
|
-
skipped: true;
|
|
29
|
-
} & BaseDumpRules) | ({
|
|
30
|
-
group: BuiltInGroup | string;
|
|
31
|
-
} & BaseDumpRules);
|
|
32
|
-
export interface CollectionOptions extends Omit<ModelOptions, 'name' | 'hooks'> {
|
|
33
|
-
name: string;
|
|
34
|
-
title?: string;
|
|
35
|
-
namespace?: string;
|
|
36
|
-
dumpRules?: DumpRules;
|
|
37
|
-
tableName?: string;
|
|
38
|
-
inherits?: string[] | string;
|
|
39
|
-
viewName?: string;
|
|
40
|
-
writableView?: boolean;
|
|
41
|
-
filterTargetKey?: string;
|
|
42
|
-
fields?: FieldOptions[];
|
|
43
|
-
model?: string | ModelStatic<Model>;
|
|
44
|
-
repository?: string | RepositoryType;
|
|
45
|
-
sortable?: CollectionSortable;
|
|
46
|
-
/**
|
|
47
|
-
* @default true
|
|
48
|
-
*/
|
|
49
|
-
autoGenId?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* @default 'options'
|
|
52
|
-
*/
|
|
53
|
-
magicAttribute?: string;
|
|
54
|
-
tree?: string;
|
|
55
|
-
template?: string;
|
|
56
|
-
/**
|
|
57
|
-
* where is the collection from
|
|
58
|
-
*
|
|
59
|
-
* values
|
|
60
|
-
* - 'plugin' - collection is from plugin
|
|
61
|
-
* - 'core' - collection is from core
|
|
62
|
-
* - 'user' - collection is from user
|
|
63
|
-
*/
|
|
64
|
-
origin?: string;
|
|
65
|
-
asStrategyResource?: boolean;
|
|
66
|
-
[key: string]: any;
|
|
67
|
-
}
|
|
68
|
-
export interface CollectionContext {
|
|
69
|
-
database: Database;
|
|
70
|
-
}
|
|
71
|
-
export declare class Collection<TModelAttributes extends {} = any, TCreationAttributes extends {} = TModelAttributes> extends EventEmitter {
|
|
72
|
-
options: CollectionOptions;
|
|
73
|
-
context: CollectionContext;
|
|
74
|
-
isThrough?: boolean;
|
|
75
|
-
fields: Map<string, any>;
|
|
76
|
-
model: ModelStatic<Model>;
|
|
77
|
-
repository: Repository<TModelAttributes, TCreationAttributes>;
|
|
78
|
-
constructor(options: CollectionOptions, context: CollectionContext);
|
|
79
|
-
get filterTargetKey(): string;
|
|
80
|
-
get name(): string;
|
|
81
|
-
get origin(): string;
|
|
82
|
-
get titleField(): string;
|
|
83
|
-
get db(): Database;
|
|
84
|
-
get treeParentField(): BelongsToField | null;
|
|
85
|
-
get treeChildrenField(): HasManyField | null;
|
|
86
|
-
tableName(): any;
|
|
87
|
-
/**
|
|
88
|
-
* @internal
|
|
89
|
-
*/
|
|
90
|
-
modelInit(): void;
|
|
91
|
-
setRepository(repository?: RepositoryType | string): void;
|
|
92
|
-
forEachField(callback: (field: Field) => void): void;
|
|
93
|
-
findField(callback: (field: Field) => boolean): any;
|
|
94
|
-
hasField(name: string): boolean;
|
|
95
|
-
getField<F extends Field>(name: string): F;
|
|
96
|
-
getFields(): any[];
|
|
97
|
-
addField(name: string, options: FieldOptions): Field;
|
|
98
|
-
checkFieldType(name: string, options: FieldOptions): void;
|
|
99
|
-
/**
|
|
100
|
-
* @internal
|
|
101
|
-
*/
|
|
102
|
-
correctOptions(options: any): void;
|
|
103
|
-
setField(name: string, options: FieldOptions): Field;
|
|
104
|
-
setFields(fields: FieldOptions[], resetFields?: boolean): void;
|
|
105
|
-
resetFields(): void;
|
|
106
|
-
remove(): Collection<any, any>;
|
|
107
|
-
removeFieldFromDb(name: string, options?: QueryInterfaceOptions): Promise<void>;
|
|
108
|
-
removeFromDb(options?: QueryInterfaceDropTableOptions & {
|
|
109
|
-
dropCollection?: boolean;
|
|
110
|
-
}): Promise<Collection<any, any>>;
|
|
111
|
-
existsInDb(options?: Transactionable): Promise<boolean>;
|
|
112
|
-
removeField(name: string): void | Field;
|
|
113
|
-
updateOptions(options: CollectionOptions, mergeOptions?: any): this;
|
|
114
|
-
setSortable(sortable: any): void;
|
|
115
|
-
updateField(name: string, options: FieldOptions): void;
|
|
116
|
-
addIndex(index: string | string[] | {
|
|
117
|
-
fields: string[];
|
|
118
|
-
unique?: boolean;
|
|
119
|
-
[key: string]: any;
|
|
120
|
-
}): void;
|
|
121
|
-
removeIndex(fields: any): void;
|
|
122
|
-
/**
|
|
123
|
-
* @internal
|
|
124
|
-
*/
|
|
125
|
-
refreshIndexes(): void;
|
|
126
|
-
sync(syncOptions?: SyncOptions): Promise<void>;
|
|
127
|
-
isInherited(): boolean;
|
|
128
|
-
isParent(): boolean;
|
|
129
|
-
getTableNameWithSchema(): any;
|
|
130
|
-
tableNameAsString(options?: {
|
|
131
|
-
ignorePublicSchema: boolean;
|
|
132
|
-
}): any;
|
|
133
|
-
getTableNameWithSchemaAsString(): string;
|
|
134
|
-
quotedTableName(): any;
|
|
135
|
-
collectionSchema(): string;
|
|
136
|
-
isView(): boolean;
|
|
137
|
-
protected sequelizeModelOptions(): {
|
|
138
|
-
modelName: string;
|
|
139
|
-
sequelize: import("sequelize").Sequelize;
|
|
140
|
-
tableName: any;
|
|
141
|
-
};
|
|
142
|
-
protected bindFieldEventListener(): void;
|
|
143
|
-
private checkOptions;
|
|
144
|
-
private checkTableName;
|
|
145
|
-
}
|