@nocobase/data-source-manager 0.21.0-alpha.15 → 0.21.0-alpha.16
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/collection-field.d.ts +1 -1
- package/lib/collection-manager.js +7 -0
- package/lib/collection.d.ts +1 -0
- package/lib/collection.js +7 -3
- package/lib/data-source.d.ts +1 -1
- package/lib/data-source.js +26 -26
- package/lib/default-actions/list.js +2 -2
- package/lib/default-actions/move.d.ts +1 -1
- package/lib/default-actions/move.js +17 -28
- package/lib/default-actions/proxy-to-repository.d.ts +2 -1
- package/lib/default-actions/proxy-to-repository.js +1 -2
- package/lib/default-actions/utils.d.ts +0 -3
- package/lib/default-actions/utils.js +0 -15
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -2
- package/lib/load-default-actions.d.ts +2 -4
- package/lib/load-default-actions.js +13 -2
- package/lib/repository.js +6 -1
- package/lib/sequelize-collection-manager.js +1 -0
- package/lib/sequelize-data-source.d.ts +0 -1
- package/lib/sequelize-data-source.js +0 -2
- package/lib/types.d.ts +6 -5
- package/package.json +7 -7
- package/lib/data-source-with-database.d.ts +0 -4
- package/lib/data-source-with-database.js +0 -15
|
@@ -28,10 +28,13 @@ const _CollectionManager = class _CollectionManager {
|
|
|
28
28
|
models = /* @__PURE__ */ new Map();
|
|
29
29
|
constructor(options = {}) {
|
|
30
30
|
}
|
|
31
|
+
/* istanbul ignore next -- @preserve */
|
|
31
32
|
getRegisteredFieldType(type) {
|
|
32
33
|
}
|
|
34
|
+
/* istanbul ignore next -- @preserve */
|
|
33
35
|
getRegisteredFieldInterface(key) {
|
|
34
36
|
}
|
|
37
|
+
/* istanbul ignore next -- @preserve */
|
|
35
38
|
getRegisteredModel(key) {
|
|
36
39
|
return this.models.get(key);
|
|
37
40
|
}
|
|
@@ -41,10 +44,13 @@ const _CollectionManager = class _CollectionManager {
|
|
|
41
44
|
}
|
|
42
45
|
return this.repositories.get(key);
|
|
43
46
|
}
|
|
47
|
+
/* istanbul ignore next -- @preserve */
|
|
44
48
|
registerFieldTypes() {
|
|
45
49
|
}
|
|
50
|
+
/* istanbul ignore next -- @preserve */
|
|
46
51
|
registerFieldInterfaces() {
|
|
47
52
|
}
|
|
53
|
+
/* istanbul ignore next -- @preserve */
|
|
48
54
|
registerCollectionTemplates() {
|
|
49
55
|
}
|
|
50
56
|
registerModels(models) {
|
|
@@ -64,6 +70,7 @@ const _CollectionManager = class _CollectionManager {
|
|
|
64
70
|
}
|
|
65
71
|
extendCollection(collectionOptions, mergeOptions) {
|
|
66
72
|
const collection = this.getCollection(collectionOptions.name);
|
|
73
|
+
collection.updateOptions(collectionOptions, mergeOptions);
|
|
67
74
|
return collection;
|
|
68
75
|
}
|
|
69
76
|
hasCollection(name) {
|
package/lib/collection.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export declare class Collection implements ICollection {
|
|
|
7
7
|
fields: Map<string, IField>;
|
|
8
8
|
constructor(options: CollectionOptions, collectionManager: ICollectionManager);
|
|
9
9
|
updateOptions(options: CollectionOptions, mergeOptions?: any): this;
|
|
10
|
+
setFields(fields: any[]): void;
|
|
10
11
|
setField(name: string, options: any): CollectionField;
|
|
11
12
|
removeField(name: string): void;
|
|
12
13
|
getField(name: string): IField;
|
package/lib/collection.js
CHANGED
|
@@ -40,9 +40,7 @@ const _Collection = class _Collection {
|
|
|
40
40
|
this.collectionManager = collectionManager;
|
|
41
41
|
this.setRepository(options.repository);
|
|
42
42
|
if (options.fields) {
|
|
43
|
-
|
|
44
|
-
this.setField(field.name, field);
|
|
45
|
-
}
|
|
43
|
+
this.setFields(options.fields);
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
repository;
|
|
@@ -51,11 +49,17 @@ const _Collection = class _Collection {
|
|
|
51
49
|
let newOptions = import_lodash.default.cloneDeep(options);
|
|
52
50
|
newOptions = (0, import_deepmerge.default)(this.options, newOptions, mergeOptions);
|
|
53
51
|
this.options = newOptions;
|
|
52
|
+
this.setFields(newOptions.fields || []);
|
|
54
53
|
if (options.repository) {
|
|
55
54
|
this.setRepository(options.repository);
|
|
56
55
|
}
|
|
57
56
|
return this;
|
|
58
57
|
}
|
|
58
|
+
setFields(fields) {
|
|
59
|
+
for (const field of fields) {
|
|
60
|
+
this.setField(field.name, field);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
59
63
|
setField(name, options) {
|
|
60
64
|
const field = new import_collection_field.CollectionField(options);
|
|
61
65
|
this.fields.set(name, field);
|
package/lib/data-source.d.ts
CHANGED
|
@@ -13,10 +13,10 @@ export declare abstract class DataSource extends EventEmitter {
|
|
|
13
13
|
get name(): any;
|
|
14
14
|
static testConnection(options?: any): Promise<boolean>;
|
|
15
15
|
init(options?: DataSourceOptions): void;
|
|
16
|
-
collectionToResourceMiddleware(): (ctx: any, next: any) => Promise<any>;
|
|
17
16
|
middleware(middlewares?: any): (ctx: any, next: any) => Promise<any>;
|
|
18
17
|
createACL(): ACL;
|
|
19
18
|
createResourceManager(options: any): ResourceManager;
|
|
20
19
|
load(options?: any): Promise<void>;
|
|
21
20
|
abstract createCollectionManager(options?: any): ICollectionManager;
|
|
21
|
+
protected collectionToResourceMiddleware(): (ctx: any, next: any) => Promise<any>;
|
|
22
22
|
}
|
package/lib/data-source.js
CHANGED
|
@@ -58,11 +58,36 @@ const _DataSource = class _DataSource extends import_events.default {
|
|
|
58
58
|
...options.resourceManager
|
|
59
59
|
});
|
|
60
60
|
this.collectionManager = this.createCollectionManager(options);
|
|
61
|
-
this.resourceManager.registerActionHandlers((0, import_load_default_actions.loadDefaultActions)(
|
|
61
|
+
this.resourceManager.registerActionHandlers((0, import_load_default_actions.loadDefaultActions)());
|
|
62
62
|
if (options.acl !== false) {
|
|
63
63
|
this.resourceManager.use(this.acl.middleware(), { tag: "acl", after: ["auth"] });
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
+
middleware(middlewares = []) {
|
|
67
|
+
const dataSource = this;
|
|
68
|
+
if (!this["_used"]) {
|
|
69
|
+
for (const [fn, options] of middlewares) {
|
|
70
|
+
this.resourceManager.use(fn, options);
|
|
71
|
+
}
|
|
72
|
+
this["_used"] = true;
|
|
73
|
+
}
|
|
74
|
+
return async (ctx, next) => {
|
|
75
|
+
ctx.dataSource = dataSource;
|
|
76
|
+
ctx.getCurrentRepository = () => {
|
|
77
|
+
const { resourceName, resourceOf } = ctx.action;
|
|
78
|
+
return this.collectionManager.getRepository(resourceName, resourceOf);
|
|
79
|
+
};
|
|
80
|
+
return (0, import_koa_compose.default)([this.collectionToResourceMiddleware(), this.resourceManager.middleware()])(ctx, next);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
createACL() {
|
|
84
|
+
return new import_acl.ACL();
|
|
85
|
+
}
|
|
86
|
+
createResourceManager(options) {
|
|
87
|
+
return new import_resourcer.ResourceManager(options);
|
|
88
|
+
}
|
|
89
|
+
async load(options = {}) {
|
|
90
|
+
}
|
|
66
91
|
collectionToResourceMiddleware() {
|
|
67
92
|
return async (ctx, next) => {
|
|
68
93
|
const params = (0, import_resourcer.parseRequest)(
|
|
@@ -93,31 +118,6 @@ const _DataSource = class _DataSource extends import_events.default {
|
|
|
93
118
|
return next();
|
|
94
119
|
};
|
|
95
120
|
}
|
|
96
|
-
middleware(middlewares = []) {
|
|
97
|
-
const dataSource = this;
|
|
98
|
-
if (!this["_used"]) {
|
|
99
|
-
for (const [fn, options] of middlewares) {
|
|
100
|
-
this.resourceManager.use(fn, options);
|
|
101
|
-
}
|
|
102
|
-
this["_used"] = true;
|
|
103
|
-
}
|
|
104
|
-
return async (ctx, next) => {
|
|
105
|
-
ctx.getCurrentRepository = () => {
|
|
106
|
-
const { resourceName, resourceOf } = ctx.action;
|
|
107
|
-
return this.collectionManager.getRepository(resourceName, resourceOf);
|
|
108
|
-
};
|
|
109
|
-
ctx.dataSource = dataSource;
|
|
110
|
-
return (0, import_koa_compose.default)([this.collectionToResourceMiddleware(), this.resourceManager.middleware()])(ctx, next);
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
createACL() {
|
|
114
|
-
return new import_acl.ACL();
|
|
115
|
-
}
|
|
116
|
-
createResourceManager(options) {
|
|
117
|
-
return new import_resourcer.ResourceManager(options);
|
|
118
|
-
}
|
|
119
|
-
async load(options = {}) {
|
|
120
|
-
}
|
|
121
121
|
};
|
|
122
122
|
__name(_DataSource, "DataSource");
|
|
123
123
|
let DataSource = _DataSource;
|
|
@@ -45,7 +45,7 @@ function findArgs(ctx) {
|
|
|
45
45
|
__name(findArgs, "findArgs");
|
|
46
46
|
async function listWithPagination(ctx) {
|
|
47
47
|
const { page = 1, pageSize = 50 } = ctx.action.params;
|
|
48
|
-
const repository =
|
|
48
|
+
const repository = ctx.getCurrentRepository();
|
|
49
49
|
const options = {
|
|
50
50
|
context: ctx,
|
|
51
51
|
...findArgs(ctx),
|
|
@@ -67,7 +67,7 @@ async function listWithPagination(ctx) {
|
|
|
67
67
|
}
|
|
68
68
|
__name(listWithPagination, "listWithPagination");
|
|
69
69
|
async function listWithNonPaged(ctx) {
|
|
70
|
-
const repository =
|
|
70
|
+
const repository = ctx.getCurrentRepository();
|
|
71
71
|
const rows = await repository.find({ context: ctx, ...findArgs(ctx) });
|
|
72
72
|
ctx.body = rows;
|
|
73
73
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Context } from '@nocobase/actions';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function createMoveAction(databaseMoveAction: any): (ctx: Context, next: any) => Promise<any>;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
6
|
var __export = (target, all) => {
|
|
@@ -17,38 +15,29 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var move_exports = {};
|
|
30
20
|
__export(move_exports, {
|
|
31
|
-
|
|
21
|
+
createMoveAction: () => createMoveAction
|
|
32
22
|
});
|
|
33
23
|
module.exports = __toCommonJS(move_exports);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
throw new Error(`Repository can not handle action move for ${ctx.action.resourceName}`);
|
|
24
|
+
function createMoveAction(databaseMoveAction) {
|
|
25
|
+
return /* @__PURE__ */ __name(async function move(ctx, next) {
|
|
26
|
+
const repository = ctx.getCurrentRepository();
|
|
27
|
+
if (repository.move) {
|
|
28
|
+
ctx.body = await repository.move(ctx.action.params);
|
|
29
|
+
await next();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (repository.database) {
|
|
33
|
+
ctx.databaseRepository = repository;
|
|
34
|
+
return databaseMoveAction(ctx, next);
|
|
35
|
+
}
|
|
36
|
+
throw new Error(`Repository can not handle action move for ${ctx.action.resourceName}`);
|
|
37
|
+
}, "move");
|
|
49
38
|
}
|
|
50
|
-
__name(
|
|
39
|
+
__name(createMoveAction, "createMoveAction");
|
|
51
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
41
|
0 && (module.exports = {
|
|
53
|
-
|
|
42
|
+
createMoveAction
|
|
54
43
|
});
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Context } from '@nocobase/actions';
|
|
2
|
+
export declare function proxyToRepository(paramKeys: string[] | ((ctx: any) => object), repositoryMethod: string): (ctx: Context, next: () => Promise<void>) => Promise<void>;
|
|
@@ -32,10 +32,9 @@ __export(proxy_to_repository_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(proxy_to_repository_exports);
|
|
34
34
|
var import_lodash = __toESM(require("lodash"));
|
|
35
|
-
var import_utils = require("./utils");
|
|
36
35
|
function proxyToRepository(paramKeys, repositoryMethod) {
|
|
37
36
|
return async function(ctx, next) {
|
|
38
|
-
const repository =
|
|
37
|
+
const repository = ctx.getCurrentRepository();
|
|
39
38
|
const callObj = typeof paramKeys === "function" ? paramKeys(ctx) : { ...import_lodash.default.pick(ctx.action.params, paramKeys), context: ctx };
|
|
40
39
|
const dataSource = ctx.dataSource;
|
|
41
40
|
if (!repository[repositoryMethod]) {
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { Context } from '@nocobase/actions';
|
|
2
|
-
import { IRepository } from '../';
|
|
3
1
|
export declare function pageArgsToLimitArgs(page: number, pageSize: number): {
|
|
4
2
|
offset: number;
|
|
5
3
|
limit: number;
|
|
6
4
|
};
|
|
7
|
-
export declare function getRepositoryFromParams(ctx: Context): IRepository;
|
|
@@ -18,7 +18,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var utils_exports = {};
|
|
20
20
|
__export(utils_exports, {
|
|
21
|
-
getRepositoryFromParams: () => getRepositoryFromParams,
|
|
22
21
|
pageArgsToLimitArgs: () => pageArgsToLimitArgs
|
|
23
22
|
});
|
|
24
23
|
module.exports = __toCommonJS(utils_exports);
|
|
@@ -29,21 +28,7 @@ function pageArgsToLimitArgs(page, pageSize) {
|
|
|
29
28
|
};
|
|
30
29
|
}
|
|
31
30
|
__name(pageArgsToLimitArgs, "pageArgsToLimitArgs");
|
|
32
|
-
function getRepositoryFromParams(ctx) {
|
|
33
|
-
const { resourceName, sourceId, actionName } = ctx.action;
|
|
34
|
-
const dataSource = ctx.dataSource;
|
|
35
|
-
if (sourceId === "_" && ["get", "list"].includes(actionName)) {
|
|
36
|
-
const collection = dataSource.collectionManager.getCollection(resourceName);
|
|
37
|
-
return dataSource.collectionManager.getRepository(collection.name);
|
|
38
|
-
}
|
|
39
|
-
if (sourceId) {
|
|
40
|
-
return dataSource.collectionManager.getRepository(resourceName, sourceId);
|
|
41
|
-
}
|
|
42
|
-
return dataSource.collectionManager.getRepository(resourceName);
|
|
43
|
-
}
|
|
44
|
-
__name(getRepositoryFromParams, "getRepositoryFromParams");
|
|
45
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
46
32
|
0 && (module.exports = {
|
|
47
|
-
getRepositoryFromParams,
|
|
48
33
|
pageArgsToLimitArgs
|
|
49
34
|
});
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -21,7 +21,6 @@ __reExport(src_exports, require("./sequelize-collection-manager"), module.export
|
|
|
21
21
|
__reExport(src_exports, require("./sequelize-data-source"), module.exports);
|
|
22
22
|
__reExport(src_exports, require("./load-default-actions"), module.exports);
|
|
23
23
|
__reExport(src_exports, require("./types"), module.exports);
|
|
24
|
-
__reExport(src_exports, require("./data-source-with-database"), module.exports);
|
|
25
24
|
__reExport(src_exports, require("./utils"), module.exports);
|
|
26
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
27
26
|
0 && (module.exports = {
|
|
@@ -32,6 +31,5 @@ __reExport(src_exports, require("./utils"), module.exports);
|
|
|
32
31
|
...require("./sequelize-data-source"),
|
|
33
32
|
...require("./load-default-actions"),
|
|
34
33
|
...require("./types"),
|
|
35
|
-
...require("./data-source-with-database"),
|
|
36
34
|
...require("./utils")
|
|
37
35
|
});
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { list } from './default-actions/list';
|
|
2
|
-
|
|
3
|
-
import { DataSource } from './data-source';
|
|
4
|
-
export declare function loadDefaultActions(dataSource: DataSource): {
|
|
2
|
+
export declare function loadDefaultActions(): {
|
|
5
3
|
list: typeof list;
|
|
6
|
-
move:
|
|
4
|
+
move: (ctx: import("@nocobase/actions").Context, next: any) => Promise<any>;
|
|
7
5
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
8
|
var __export = (target, all) => {
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var load_default_actions_exports = {};
|
|
20
30
|
__export(load_default_actions_exports, {
|
|
@@ -24,6 +34,7 @@ module.exports = __toCommonJS(load_default_actions_exports);
|
|
|
24
34
|
var import_list = require("./default-actions/list");
|
|
25
35
|
var import_move = require("./default-actions/move");
|
|
26
36
|
var import_proxy_to_repository = require("./default-actions/proxy-to-repository");
|
|
37
|
+
var import_actions = __toESM(require("@nocobase/actions"));
|
|
27
38
|
const actions = {
|
|
28
39
|
add: {
|
|
29
40
|
params(ctx) {
|
|
@@ -83,14 +94,14 @@ const actions = {
|
|
|
83
94
|
method: "toggle"
|
|
84
95
|
}
|
|
85
96
|
};
|
|
86
|
-
function loadDefaultActions(
|
|
97
|
+
function loadDefaultActions() {
|
|
87
98
|
return {
|
|
88
99
|
...Object.keys(actions).reduce((carry, key) => {
|
|
89
100
|
carry[key] = (0, import_proxy_to_repository.proxyToRepository)(actions[key].params, actions[key].method);
|
|
90
101
|
return carry;
|
|
91
102
|
}, {}),
|
|
92
103
|
list: import_list.list,
|
|
93
|
-
move: import_move.move
|
|
104
|
+
move: (0, import_move.createMoveAction)(import_actions.default.move)
|
|
94
105
|
};
|
|
95
106
|
}
|
|
96
107
|
__name(loadDefaultActions, "loadDefaultActions");
|
package/lib/repository.js
CHANGED
|
@@ -32,6 +32,7 @@ __export(repository_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(repository_exports);
|
|
34
34
|
var console = __toESM(require("console"));
|
|
35
|
+
/* istanbul ignore file -- @preserve */
|
|
35
36
|
const _Repository = class _Repository {
|
|
36
37
|
async create(options) {
|
|
37
38
|
console.log("Repository.create....");
|
|
@@ -42,7 +43,11 @@ const _Repository = class _Repository {
|
|
|
42
43
|
return [];
|
|
43
44
|
}
|
|
44
45
|
async findOne(options) {
|
|
45
|
-
return {
|
|
46
|
+
return {
|
|
47
|
+
toJSON() {
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
};
|
|
46
51
|
}
|
|
47
52
|
async destroy(options) {
|
|
48
53
|
}
|
|
@@ -32,6 +32,7 @@ __export(sequelize_collection_manager_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(sequelize_collection_manager_exports);
|
|
34
34
|
var import_database = __toESM(require("@nocobase/database"));
|
|
35
|
+
/* istanbul ignore file -- @preserve */
|
|
35
36
|
const _SequelizeCollectionManager = class _SequelizeCollectionManager {
|
|
36
37
|
db;
|
|
37
38
|
options;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DataSource } from './data-source';
|
|
2
2
|
import { SequelizeCollectionManager } from './sequelize-collection-manager';
|
|
3
3
|
export declare class SequelizeDataSource extends DataSource {
|
|
4
|
-
load(): Promise<void>;
|
|
5
4
|
createCollectionManager(options?: any): SequelizeCollectionManager;
|
|
6
5
|
}
|
|
@@ -24,8 +24,6 @@ module.exports = __toCommonJS(sequelize_data_source_exports);
|
|
|
24
24
|
var import_data_source = require("./data-source");
|
|
25
25
|
var import_sequelize_collection_manager = require("./sequelize-collection-manager");
|
|
26
26
|
const _SequelizeDataSource = class _SequelizeDataSource extends import_data_source.DataSource {
|
|
27
|
-
async load() {
|
|
28
|
-
}
|
|
29
27
|
createCollectionManager(options) {
|
|
30
28
|
return new import_sequelize_collection_manager.SequelizeCollectionManager(options.collectionManager);
|
|
31
29
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -24,8 +24,8 @@ export interface IField {
|
|
|
24
24
|
options: FieldOptions;
|
|
25
25
|
}
|
|
26
26
|
export interface ICollection {
|
|
27
|
-
repository:
|
|
28
|
-
updateOptions(options:
|
|
27
|
+
repository: IRepository;
|
|
28
|
+
updateOptions(options: CollectionOptions, mergeOptions?: MergeOptions): void;
|
|
29
29
|
setField(name: string, options: any): IField;
|
|
30
30
|
removeField(name: string): void;
|
|
31
31
|
getFields(): Array<IField>;
|
|
@@ -33,6 +33,7 @@ export interface ICollection {
|
|
|
33
33
|
[key: string]: any;
|
|
34
34
|
}
|
|
35
35
|
export interface IModel {
|
|
36
|
+
toJSON: () => any;
|
|
36
37
|
[key: string]: any;
|
|
37
38
|
}
|
|
38
39
|
export interface IRepository {
|
|
@@ -40,9 +41,9 @@ export interface IRepository {
|
|
|
40
41
|
findOne(options?: any): Promise<IModel>;
|
|
41
42
|
count(options?: any): Promise<Number>;
|
|
42
43
|
findAndCount(options?: any): Promise<[IModel[], Number]>;
|
|
43
|
-
create(options: any):
|
|
44
|
-
update(options: any):
|
|
45
|
-
destroy(options: any):
|
|
44
|
+
create(options: any): any;
|
|
45
|
+
update(options: any): any;
|
|
46
|
+
destroy(options: any): any;
|
|
46
47
|
[key: string]: any;
|
|
47
48
|
}
|
|
48
49
|
export type MergeOptions = {
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/data-source-manager",
|
|
3
|
-
"version": "0.21.0-alpha.
|
|
3
|
+
"version": "0.21.0-alpha.16",
|
|
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": "0.21.0-alpha.
|
|
10
|
-
"@nocobase/cache": "0.21.0-alpha.
|
|
11
|
-
"@nocobase/database": "0.21.0-alpha.
|
|
12
|
-
"@nocobase/resourcer": "0.21.0-alpha.
|
|
13
|
-
"@nocobase/utils": "0.21.0-alpha.
|
|
9
|
+
"@nocobase/actions": "0.21.0-alpha.16",
|
|
10
|
+
"@nocobase/cache": "0.21.0-alpha.16",
|
|
11
|
+
"@nocobase/database": "0.21.0-alpha.16",
|
|
12
|
+
"@nocobase/resourcer": "0.21.0-alpha.16",
|
|
13
|
+
"@nocobase/utils": "0.21.0-alpha.16",
|
|
14
14
|
"@types/jsonwebtoken": "^8.5.8",
|
|
15
15
|
"jsonwebtoken": "^8.5.1"
|
|
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": "2914500f14e4454cc5702a49371230865660ca33"
|
|
23
23
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
-
for (let key of __getOwnPropNames(from))
|
|
8
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
-
}
|
|
11
|
-
return to;
|
|
12
|
-
};
|
|
13
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
-
var data_source_with_database_exports = {};
|
|
15
|
-
module.exports = __toCommonJS(data_source_with_database_exports);
|